Indenting in Vim

Ever had that situation where you've enabled :set paste and pasted in hundred of lines of code into vim only to see it all fully left aligned? I just did… And bugger going over each line and manually indenting it! Want know how to indent a visual block of text?


So, make a visual selection of what you'd like indented (by pressing v and moving the cursor to mark the selection). Press colon to enter command mode and type "le2". The le command is shorthand for left align. The 2 value is an optional indent setting.

This is what I love about vim; there is always a new trick to make your life easier!