tags:

views:

111

answers:

3

I am currently visually selecting the code and typing ">" which moves the code by 2 tabs. But I only want to move it by one tab.

Is there any alternate command in VIM to move the code by a tabspace. Ideally I would like to put a marker and then move the whole code block by a tabspace. Thanks

+2  A: 

This will set your shifting width to four spaces (default tab size):

:set sw=4

You can also change the size of the tab stop itself (X is any value you like):

:set ts=X

And if you like to use spaces instead of tab characters, use this:

:set expandtab

If you use the same settings in many files, you can put these in your .vimrc.

Marcin
Thanks, that fixed the issue.
VNarasimhaM
+2  A: 

> moves the code by one shiftwidth. So you need to set that option correctly.

Aaron Digulla
But which option? Not as helpful an answer as the one by Marcin.
Jonathan Leffler
The option "shiftwidth" (or "sw" for short). Just follow the link to the docs.
Aaron Digulla
+1  A: 

There are easier ways to do what you want, as others have pointed out, but the following is of more general use:

  • You can select a column by pressing ctrl+v and then using the up and down keys (or j and k).
  • Next press I to go to insert mode. Now you can type anthing you like. In your case, type a single tab.
  • Finish by pressing esc, and see how your edit is applied to all lines.
Stephan202
I'm not sure that I'd regard that as easier than using the shift operators for shifting text, but it is interesting to see what the visual block does - so +1 for that.
Jonathan Leffler