开发者

Entab / Detab in VIM

In normal text editors, you select the b开发者_Python百科lock of text and then press Tab to entab and Shift + Tab to detab.

How do I entab or detab a selected block of text in VIM?


If you select the text and hit ">" it will indent, and "<" will de-indent.

Whether it inserts tabs or spaces depends on your "expandtab" setting. You can edit the number of spaces/tabstop with the "shiftwidth" and "tabstop" settings.


In addition to Andy White's answer. I would also add the following into vimrc:

vnoremap > >gv
vnoremap < <gv

So you wouldn't need to reselect your code block to indent/dedent further.


You don't even need to select the text. You can indent/unindent the current line by hitting >> or <<.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜