Subsections

5. Editors


There is a large number of text editors available for unix systems. For historical reasons «the» editors are vi and emacs. There is at least one good reason to learn the basics of vi and emacs: they are available almost everywhere. In fact many unix commands use vi as default editor.

5.1 vi

Start the vi editor with vi your file name. The vi editor has two running modes: command and insert mode. Command mode is the default at startup. In this mode all letters on your keyboard have a meaning and send a command to the editor. To switch to insert mode and insert a text into the file you must press <i> (or <insert>) or <a> (add). After that everything you type in your keyboard will be inserted in the file as text. To exit the insert mode and return to command mode hit <esc> or <ctrl-[>.

vi command quick reference
cursor movement arrow keys
scroll up <ctrl-u> or <ctrl-b>
scroll down <ctrl-d> or <ctrl-f>
go to top <1><G>
go to bottom <G>
go to line number n n<G>
find backward <?>string to search<return>
find forward </>string to search<return>
find next (same direction) <n>
find next (opposite direction) <N>
delete character at cursor <x>
delete a line <d><d>
delete to end-of-line <d><$>
delete word at cursor <d><w>

5.2 emacs

When you are using emacs the screen is divided into a number of windows. The text window can be divided horizontally or vertically into multiple text windows, each of which can be used for a different file. The complete manual of emacs is available in the S.I.S.S.A. library. There is nothing special you have to do to write your text, all commands are issued using the <ctrl> key.

emacs command quick reference
save buffers and exit <ctrl-x><ctrl-c>
delete character at cursor <del>
move to the beginning of the line <ctrl-a>
move to the end of the line <ctrl-e>
refresh screen <ctrl-l>
delete to the end of line <ctrl-k>
display help <ctrl-h>
find forward <ctrl-s>string to search<return>
find backward <ctrl-r>string to search<return>

5.3 Other popular editors: pico, mcedit, joe

pico is a very simple, display-oriented text editor. Commands are displayed at the bottom of the screen, and context-sensitive help is provided. As characters are typed they are immediately inserted into the text. Editing commands are entered using the <ctrl> key. See man pico or the internal help, accessed with <ctrl-h> from pico.

mcedit is the internal editor of the mc (Midnight Commander) file manager. All commands are available via hot-keys <F1> to <F10> as shown at the bottom of the screen, or via the menu system.

joe is another powerful editor. Key-bindings for useful commands are shown on-screen hitting <ctrl-k><h>. joe can mimic the behaviour of other editors if invoked with different names: jstar (Borland Wordstar), jmacs (emacs), jpico (pico).

5.4 X11 editors

Many other editors are available when working in graphical environments: xemacs (X11 version of emacs), kate and kwrite (KDE environment), gedit (Gnome environment), nedit. They all have a menu-driven interface and an on-line help.

Piero Calucci 2004-11-05