How to keep tab without block loss

I have been using vim for about 3 weeks and have tab issues.

What I usually do is do gg to go to the beginning, do ctrl+v for the visual block, do G to select everything below (one column), do $ to select on the right, then click on the < or > tab .

However, to do all this, I lost the selection, and I need to do all of these commands to make another tab.

How not to lose selection? Or is there a better way?

NOTE. Sometimes I don’t have to select anything, just a part of the file.

+7
source share
2 answers

To re-select the visual selection, use the gv command followed by your command. Although this is not the best way.

Instead, select the entire buffer with ggVG , then indent with > . This will indent the selection. To repeat the command again, simply press . . Team will repeat the last normal command, in this case the > command. If you have indented several times, just use the cancel command, u as many times as necessary. This vimcast is a great screencast describing this technique, and this one is described by more indentation methods.

Others prefer the following comparisons:

 xnoremap <Tab> >gv xnoremap <S-Tab> <gv 
+11
source

I’m not sure what is important here: to be able to indent several times in a single pass or save a visual block. Assuming you want to indent a few, just the prefix > with a number, for example. 3> selected block will retreat three times.

In addition, you do not need to select the entire line for indentation (i.e. $ not required).

+3
source

All Articles