How do I indent a single line multiple times in vi or vim?

I've found several answers on how to indent multiple lines in vim, I want to know how to take a single line and indent it more than once. In effect, I want a shorter version of the following command: ">>>>>>>>>>" (That is 10 right bracket "greater-than" signs.)


Select what you want (typically with v or Shift+v) then type 5> .

If you need to fix or repeat the same selection, use gv.


您可以通过按v选择当前行,然后输入5>以缩进当前行5次,相当于按> 10次​​。


One of the answers to "How do I indent multiple lines quickly in vi" showed me a neat trick to remap > in visual mode to reselect visual mode. In your .vimrc ...

vnoremap < <gv
vnoremap > >gv

Then I just select the line (or lines) you want to indent and press the appropriate direction as many times as you want.

链接地址: http://www.djcxy.com/p/4904.html

上一篇: Google托管图书馆不必要地使用缓存破坏者

下一篇: 如何在vi或vim中多次缩进单行?