Escape toggles between Command mode and Execution mode
Command mode
To scroll through document you use (small letters only!!!)
j = down one line
k = up one line
l = move one space to the right
h = move one space to the left
x = delete character
r = replace character
i = insert character(s)
u = undo
dd = delete line
yy = yank line (save it in buffer and paste with p command)
p = paste
s = delete and replace with a character typed subsequently
/[character string] = search for indicated character string in the file
n = search again for the character string in the buffer selected by /
To perform any of these multiple times use a number preceding the command.
For example,
10x = delete next 10 characters
25j = go down 25 lines
4s = delete the next four characters and replace with as many characters as typed until Esc is hit.
Type Q or Esc to enter Execution mode
Execution mode
To quit the document type
:q (quit without making any changes)
:q! (quit and do not save any changes made)
:w (write the changes to the document, but do not quit)
:wq (write changes and quit)
:set number (indicate line numbers on left margin)
:1,10w [filename] (write line numbers 1 through 10 to a file)
:r [filename] (insert contents of filename here)
:1 (go to line number 1 or any indicated line number)
:1,$s/a/b/g (global replacement of a by b from line one to the end)
:.,$s/a/b/g (global replacement of a by b from the current line to the end)
Type visual or Esc to reenter Command mode