Cheat sheet

Visual modeShift + v
Visual block ModeCtrl + v
go to line 5555 gg
GGo to the end of the document

Block comment/uncomment

  • Comment: Go into visual block mode
  • shift-i to insert, add a # (or any other comment sign)
  • the symbol appears in the first line
  • esc and it gets copied on every line (it happens only after the -esc !!)
  • Uncomment: Select in visual block mode and delete.


In normal mode, type >> to indent the current line, or << to unindent. Each command can be used with a count. The operators > and < do the same for motions, text objects and visual selections. For all commands, pressing . repeats the operation.

For example, typing 5>>.. shifts five lines to the right, and then repeats the operation twice so that the five lines are shifted three times.

In insert mode, Ctrl-T indents the current line, and Ctrl-D unindents.

When indenting or unindenting, lines are shifted one 'shiftwidth' to the right or left.

:set shiftwidth=4



  • % indicates the entire file
  • s is for “substitute” (or only search)
  • g global, replace all occurrences in the line (not only the first)
:8,10 s/search/replace/g

Replace backslah (\) with slash (/)




syntax on
set background=dark
:command W w
:command Q q


Add comment to file for indentation and stuff

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet