Skip to content

Vim

Write file opened as ‘readonly’

:w !sudo tee "%"

Visual editing can be used to delete any number of lines

Shift+V from point of cursor and press D key to delete

Search and replace

:%s/search/replace/g

Disable search highlight

:noh

Prepend multiple lines with a character

  • Shift+V from point of cursor to enter Visual Block mode
  • Move up/down to select multiple lines
  • : to enter commands
  • s/^/#/g to replace first character on the lines with a #

The prompt will look something like when all done: :'<,'>s/^/#/g