Linux vi Text Editor command help

17th June, 2009 - 2 minutes read

The vi command in Linux provides the most basic of text editing capabilities from the command line. It is both useful and at the same time extremely clunky without the proper command knowledge. Most of my searching on the web has resulted in many pages assuming that if you know the vi command then you must also know how to use it… I Linux therefore I am, or some such.

However to someone that generally doesn’t need to use the editor that often it can be frustrating trying to make a single character change in a file only accessible via SSH without having to copy the file to a desktop machine, change and copy back. Luckily I have found the following command cheatsheet for the editor:

ctrl-F :Page down
ctrl-B :Page up
$ :Move cursor to end of line
^ :Move cursor to beginning of line
:1 :Move to first line of file
:$ :Move to last line of file
/ :Search for a character string
? :Reverse search for a character string
x :Delete the character at the cursor
dd :Delete the current line
p :Paste data that was cut with x or dd commands
u :Undo

a :Add text after cursor
i :Insert text before cursor
R :Replace text starting at the cursor
o :Insert a new line after the current

esc :Switch from Input mode to Command mode

:w :save without exiting
ZZ :Save and exit
:q! :Exit without saving

So far this small but concise list has proved extremely helpful, all of a sudden the linux vi editor has become a very handy tool to have.