VIM commands

Quick VIM commands for common editing tasks

Search and replace

  • :s/foo/bar/g – change ‘foo’ to ‘bar’ in the current line
  • :%s/foo/bar/g – change ‘foo’ to ‘bar’ in all lines

Cut and paste

  1. position cursor where you want to begin cutting
  2. press ‘v’ (upper ‘V’ to cut whole lines)
  3. move cursor to end of selection
  4. press ‘d’ to cut, or ‘y’ to copy
  5. move cursor to where you would like to paste
  6. press ‘P’ to paste before cursor, or ‘p’ to paste after

That’s all!

 

You may also like...

Leave a Reply