EMZETT.
Login

Terminal text editors: nano, vim and Emacs

In short: Servers often have no graphical interface. There you edit files with terminal editors. nano is the simplest, vim and Emacs are powerful but need learning.

nano

Like a normal text program: just type. The shortcuts are shown at the bottom (^ means Ctrl).

  • Ctrl+O save, Ctrl+X quit, Ctrl+W search, Ctrl+K cut line.

Start: nano file.txt. Ideal for beginners and quick changes.

vim

The trick: vim has modes.

  • Normal mode (start): keys are commands. h j k l move, dd delete line, yy copy, p paste, u undo.
  • Insert mode: enter with i, types normal text, Esc back.
  • Command mode: :w save, :q quit, :wq both, :q! without saving, /word search.

If you are stuck: Esc, then :q!. vimtutor is a built-in exercise of about 30 minutes. Vim (or the similar vi) is available almost everywhere.

Emacs

An extensible “operating system inside an editor” programmed in Lisp (email, notes, Git). Shortcuts with Ctrl and Meta (Alt), for example Ctrl+X Ctrl+S save, Ctrl+X Ctrl+C quit.

Which one?

For daily use on servers nano is enough. Whoever programs a lot in the terminal learns vim basics because they run everywhere. See also IDE for the graphical variant.

See also: tmux and screen: several terminals in one