\" which moves the code by 2 tabs. But I only want to move it by one tab." />
开发者

Moving a block of code by a tabspace

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 a开发者_运维技巧ny 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


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.


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


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.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜