Top 5: Best Unix CLI file editors

Top 5: Best Unix CLI file editors

If you are pretty lazy and don't like to open an SFTP connection to your server, download files and edit them locally or you are working with huge files that need to be edited remotely, then the term CLI editor is without a doubt a familiar word for you. They're widely used to modify configuration files in the server without handling such files on versioning software like Git or Subversion. Many of us are accustomed to use a single CLI editor, the one with which we learned for the first time to edit a file in a terminal, however not everybody knows that are a plenty options to your CLI editor that you can learn to use as well with your favorite editor.

In this article we'll share with you 5 of the most used CLI file editors that you can use on Unix environments.

5. Midnight Commander

Midnight Commander CLI Editor

GNU Midnight Commander is a visual file manager, licensed under GNU General Public License and therefore qualifies as Free Software. It's a feature rich full-screen text mode application that allows you to copy, move and delete files and whole directory trees, search for files and run commands in the subshell. Internal viewer and editor are included. Midnight Commander is based on versatile text interfaces, such as Ncurses or S-Lang, which allows it to work on a regular console, inside an X Window terminal, over SSH connections and all kinds of remote shells.

To edit a file with this tool, you only need to run the following command:

mcedit file.txt

4. JOE Editor

JOE CLI Editor

JOE is a full featured terminal-based screen editor which is distributed under the GNU General Public License (GPL). JOE has been around since 1988 and comes standard with many Linux distributions. JOE is a blending of MicroPro's venerable microcomputer word processor WordStar and Richard Stallman's famous LISP based text editor GNU-EMACS (but it does not use code from either program): most of the basic editing keys are the same as in WordStar as is the overall feel of the editor. JOE also has some of the key bindings and many of the powerful features of EMACS.

JOE is written in C and its only dependency is libc. This makes JOE very easy to build (just "configure" and "make install"), making it feasible to include on small systems and recovery disks. The compiled binary is about 300K in x86. Note that JOE can use either the termcap or terminfo terminal capabilities databases (or a built-in termcap entry for ANSI terminals). The choice is controlled by a "configure" option. If terminfo is used, a library is required to access the database (on some systems this library is ncurses, but JOE does not use curses to control the terminal- it has its own code for this). 

joe file.txt

Much of the look and feel of JOE is determined by its simple configuration file "joerc". Several variants of the editor are installed by default in addition to "joe": "jmacs" (emulate GNU-EMACS), "jstar" emulate WordStar, "jpico" emulate the Pine mailer editor PICO and "rjoe"- a restricted version of JOE which allows the used to only edit the file given on the command line. JOE is linked to several names. The name which is used to invoke the editor with "rc" tacked on the end gives the name of configuration file to use. It is thus easy for you to make your own variant if you want. Also you can customize the editor by copying the system "joerc" file to your home directory. The Joe editor features:

  • Multi-file search and replace- file list is either given on command line or by a UNIX command (grep/find) run from within JOE.
  • Mouse support, including wheel (works best when using xterm). The mouse can resize windows, scroll windows, select and paste text, and select menu entries.
  • Context display on status line: allows you to see name of function cursor is in.
  • UTF-8 support, optional auto-detect of UTF-8 files.
  • Syntax highlighting for more than 40 languages.
  • Hexadecimal edit mode. Use JOE as a disk editor: joe -overwrite -hex /dev/hda1,0,512 (edit first sector of /dev/hda1).
  • Non-destructive editing of binary files even when handling MS-DOS or UNIX line endings.
  • Swap file allows editing files larger than memory.
  • Context sensitive on-line help.
  • Bash-like TAB completion and history for all prompts, or jump into the completion menu and use it to traverse the file system.
  • Complete word in edit buffer by hitting ESC Enter (uses other words in buffer for dictionary).
  • EMACS-compatible file locks and file modification checking.
  • Shell windows.
  • Multiple-windows onto same or different files.
  • Compile and step through errors or Grep and step through finds.
  • Goto matching character delimiter "() [] {} <>" which skips comments and quoted matter.
  • Goto matching word delimiter, including XML tags and C preprocessor directives.
  • Ctrl-arrow key block selection.
  • Search and replace system, including regular expression and optional incremental search. Regular expression key for matching balanced C expressions.
  • Tags file search (tab completion at tags search prompt uses tags file as database).
  • Spell check commands which invoke aspell or ispell. Language for aspell can be passed through editor.
  • Paragraph format which preserves news/mail quoting indentation characters.
  • Unlimited Undo and Redo.
  • Yank buffer allows stepping through and insertion of previously deleted text.
  • State file restores history buffers, yank buffer and last file cursor positions.
  • Cursor position history allows you to step through previously visited areas of a file.
  • Multiple interactive keyboard macros. Macros can be assigned to key sequences in joerc file.
  • Block move/copy/delete/filter.
  • Rectangle (columnar) block mode- search and replace can be narrowed to the rectangular block. Rectangular blocks can be filtered through UNIX commands.
  • Overtype/Insert modes.
  • Indent/Unindent (shift block left or right).
  • Auto-indent mode.
  • Picture mode for ASCII graphics.
  • Line number mode displays line number of each line.
  • Powerful scientific calculator with block statistics functions (sum/standard-deviation/count highlighted block of numbers).
  • Termcap/Terminfo support allows JOE to use any terminal or terminal emulator.
  • Can accept data from a pipe, for example: ls | joe

3. GNU Nano

GNU Nano Editor

GNU nano is designed to be a free replacement for the Pico text editor, part of the Pine email suite from The University of Washington. It aims to "emulate Pico as closely as possible and perhaps include extra functionality". Initially, the project was named TIP, but then it was officially renamed to nano because of a namespace conflict with another program called 'tip'. The original 'tip' program "establishes a full duplex terminal connection to a remote host", and was included with many older Unix systems (and newer ones like Solaris). To edit a file with nano, you just need to run the following command:

nano file.txt

2. VIM

VIM CLI Editor

Vim is a highly configurable text editor for efficiently creating and changing any kind of text. It is included as "vi" with most UNIX systems and with Apple OS X. Among its features are:

  • persistent, multi-level undo tree
  • extensive plugin system
  • support for hundreds of programming languages and file formats
  • powerful search and replace
  • integrates with many tools

To edit a file with vim, run the following command:

vim file.txt

1. GNU Emacs

GNU Emacs

GNU Emacs is an extensible, customizable, self-documenting real-time display editor, without X11 support. Emacs offers a much longer list of commands than the other widely-used UNIX text editor, vi and the ability to extend the interface. GNU Emacs is written in C, designed for a Unix or Unix-like kernel. It includes its own Lisp interpreter which is used to execute the portion of the editor that is written in Lisp.

To edit a file with Emacs, run the following command:

emacs file.txt

If you know another awesome CLI text editor, please share it with the community in the comment box.

Become a more social person