Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
575 views
in Technique[技术] by (71.8m points)

vim - Tabbing visual selection

In many GUIs when I select a section of text and then hit the Tab or Shift+Tab button the selected section will indent in or out.

In VIM I can select a visual section and then hit the < or > key to change indenting, however once I hit the < key my selection is cleared so I am stuck selecting the section again and hitting < again. This gets really annoying when I am trying to indent something a few stops in and want visual feedback.

Is there anyway to indent stuff in and out in vim while keeping the current selected text selected?

Is there a trick to re-map Tab and Shift+Tab so they behave in this way in visual mode?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can prefix a number, ie. 2> to indent two tab stops. Or, you can use > to indent once, then . to indent again (this works even though the block is no longer highlighted). If you go too far, u will undo one step at a time.

Another useful command is gv to restore the last visual block if you need to apply a different command.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...