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
- position cursor where you want to begin cutting
- press ‘v’ (upper ‘V’ to cut whole lines)
- move cursor to end of selection
- press ‘d’ to cut, or ‘y’ to copy
- move cursor to where you would like to paste
- press ‘P’ to paste before cursor, or ‘p’ to paste after
That’s all!