Vim tips and tricks

Vim is a very powerful text editor designed for productivity. You can also using gui versions like gvim or MacVim.


Below I have listed some settings in vim which make your editing life easier.

Comment selected lines

Visually select the lines you want to comment using SHIFT + v. Then press semi-colon ":" which will give you


Then type

:'<,'> s/^/#

Getting file browser

If you are editing some code which is in multiple files, it is useful to have a file browser. The plugin NERDTree provides such a file browser. After starting vim, gvim or macvim, type


to get the file browser. You can double click a file to open it.

Setting up


  1. Best of VIM Tips