One minor pet peeve I had with Vim has been resolved by this neat little trick. Commenting out multiple lines in Python has always been somewhat of a chore for me in Vim. Thankfully, it is actually quite easy:
Hit Ctrl+V Select the lines you want to comment out (don’t use the mouse for that) Hit “0″ + “I” (capital i) to write simultaneously at the beginning of the selected lines type “#” Hit “ESC”
Update: it’s actually even easier (thank you to Tobi for pointing out this most elegant use case of search and replace in Vim):
- Hit Shift+V to select the lines you want to comment out.
- Enter “:s/^/#/g” to search and “replace” (in this case insert) # at the linestart.
Job’s done. One very neat little trick.