Guide to Unix/Commands/File Editing

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Unix and Unix-like operating system come with a multitude of terminal editors. An editor codified in POSIX is vi, widely available on Unix variants. A small selection of other terminal editors follows.

joe[edit | edit source]

A plain-text editor with syntax-coloring support whose editing keys are based on MicroPro's word processor WordStar.


pico[edit | edit source]

Pico is an easy-to-learn text editor originally designed for composing e-mail in Pine.


nano[edit | edit source]

GNU nano is a clone of Pico. The license is GNU GPL V3[1]. Nano runs in a console window. Some commands are invoked using Control + key combinations; other commands are invoked using Meta + key, where Meta includes pressing Alt simultaneously or pressing Esc before.

A Windows version can be obtained from[2]; the source code seems to be at github[3]. Windows version used to be hosted at SourceForge[4], up to a 2002 version 1.0.8.

Warning: Some nano versions have hard line wrapping enabled by default. As a consequence, when you enter characters into a long line, nano automatically inserts a newline into it to limit its length. When inadvertent, this can cause trouble, especially when editing configuration files. You can disable the hard wrapping temporarily via Meta + L (Alt + L), or by running nano with -w option, or by placing "set nowrap" into .nanorc configuration file.

Help is available by pressing F1 or Control + G. You can search in the help by pressing slash (/); to find next occurrence, press N.

Keyboard shortcuts are listed in the help. Some of them are listed at the bottom two lines all the time unless hidden. Nano does not use the CUA keyboard shortcut convention familiar from some operating systems, so it does not use Control + C and Control + V for copying and for pasting. Keyboard shortcuts include the following:

  • Control + X: Quit the editor, or if more than one buffer is opened, close the current buffer.
  • Control + S: Save the current buffer without asking for a file name or confirmation unless there is no file name associated with the current buffer yet.
  • Control + O: Save the current buffer, asking for confirmation of the file name even if the buffer already has a file name.
  • Control + R: Insert the content of a file into the current buffer, or if so set via Alt + F, into a new buffer.
  • Control + W: Search. After pressing the shortcut, options such as regex search can be enabled by further shortcuts appearing at the bottom.
  • Alt + R: Search and replace. Regex option is available.
  • Shift + arrow keys or home and end: Selects a region.
  • Control + K: Cut the current selection, or if there is no selection, the current line. The cut text is placed into nano-internal cut buffer rather than to the system clipboard.
  • Control + U: Paste what has been cut with Control + K, thus "uncut". Does not paste the system clipboard content, it seems.
  • And more.


vi[edit | edit source]

A powerful editor based on ex. For details see the Wikibooks Learning the vi Editor.

Vim is a vi-compatible editor with more features.


emacs[edit | edit source]

A very powerful editor that is used by many programmers. See also Emacs.


zile[edit | edit source]

A light-weight, feature-reduced clone of Emacs.


See also[edit | edit source]

Links[edit | edit source]