Entab / Detab in VIM

In regular text editors, you select a block of text, and then press Tab to entab and Shift + Tab to define.

How do I paste or highlight a selected block of text in VIM?

+6
vim entab-detab
source share
3 answers

If you select the text and press ">", it will indent and "<" will indent.

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

+10
source share

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

vnoremap > >gv vnoremap < <gv 

This way, you will not need to reselect your code block for indentation / selection.

+4
source share

You don’t even need to select text. You can reverse / cancel the current line by pressing >> or << .

+3
source share

All Articles