How to avoid getting lost between vi and Emacs#

Two major editors for Linux: Vi and Emacs. There are few opportunities to use either of them, and if you are unfamiliar with them, you can easily get lost. Therefore, we have put together an article with the aim of covering even the bare minimum of operations.

vi - If you have trouble, press ESC key to normal mode#

Note

The vi system has the concept of modes, and operations differ depending on the mode. First, it is important to check the current mode.

operation

key

Mode switching

i (insert) / ESC (command)

keep

:w Enter

end

:q / Force :q!

Save + Exit

:wq or ZZ

Move (character)

h j k l

Move (global)

gg beginning / G ending

search

/string → next n

cancel

u (go back) / Ctrl-r (redo)

Hint

  • ESC for now — If in doubt, use ESC to return to normal mode

  • hjkl = cursor key — Beginners can use the D-pad. Those who want to master it should learn hjkl

Emacs - If in doubt, press C-g to cancel#

Note

C-x or C-c means hold down the Ctrl key and press x or c.

operation

key

keep

C-x C-s

end

C-x C-c

cancel

C-/ or C-_

cancel

C-g (hit repeatedly during panic)

Move (character)

C-f right / C-b left / C-n bottom / C-p top

Move (beginning/end of line)

C-a Start of line / C-e End of line

search

C-s (incremental)

Help

C-h t (official tutorial)

Hint

  • C-g interrupts anyway — “emergency exit” in case of incorrect operation

  • 30 minute tutorialC-h t starts the tutorial

Reference information

Article information

Post date:

2025-05-07

author:

Mr. Takagi