Re-format text blocks to wrap to a fixed character width

  1. Set the text width in characters :set textwidth=80
  2. Select the lines of text you want to re-format v to use visual selection
  3. Reformat gq
  4. To reformat a single paragraph without selecting it first {gq}

Turn on (or off) line numbering

  1. To turn on line numbering, at the : prompt type set number
  2. To turn off line numbering, type the command set nonumber
  3. To set relative line numbers set relativenumber

Insert a comment character as the first character in a sequence of lines (i.e., comment a block)

  1. Position the cursor on the first character in the first line to be commented
  2. Press Ctrl-V to enter VISUAL BLOCK mode
  3. Use arrow keys to select the first character in each line until the last line in sequence
  4. Press Shift-I (the i key), which will put the editor in INSERT mode
  5. Press #, the character to be inserted at the start of each line, note that it will not yet appear on screen
  6. Press Esc (wait a couple of seconds), the # character will appear at the start of each line

Remove comment characters from multiple lines

  1. Assuming # is the comment character, put your cursor on the first # character, press Ctrl-V
  2. Use arrow keys to go down until the last commented line, the first character in each line should be highlighted
  3. Press x to delete all the selected # characters