Indenting two spaces a selection (visual mode) in vim?

Provided your sw is two, you can do visually select three lines (V) and do a >. You can also select column of one space and three lines (ctrl-v), hit s and replace the said space with three spaces, then hit esc and all three lines will benefit from this improvements. And there are more ways I'm sure. Normally, you'd do the > and have your sw set to whatever indentation you want in your code.


Youre friend here are :le and :ri:

:[range]ri[ght] [width]                                 :ri :right  

     Right-align lines in [range] at [width] columns
     (default 'textwidth' or 80 when 'textwidth' is 0). 
     {not in Vi}

:[range]le[ft] [indent]                                 :le :left     

       Left-align lines in [range].  Sets the indent in the        
       lines to [indent] (default 0).  {not in Vi}

Thus just visually select your lines, and then execute one of the aboves like:

:'<,'>ri 2

or

:'<,'>le 5

(Note: the '<,'> part is automatically created by VIM, it's the content that you have visually selected)


after you select lines in visual mode. enter ":", the "'<,'>" will auto added, then enter norm I and two space(space key).

:'<,'>norm I<space><space>