How to keep in visual mode after identing by shift+> in vim?

You can use the normal mode command gv to highlight the previous visual selection. Therefore, you could use the following mappings:

:vnoremap < <gv
:vnoremap > >gv

The :vnoremap command sets up a mapping that will work only in visual mode. You are therefore rebinding the < and > visual mode commands to perform the indent and immediately re-select the previous visual selection.


Using period "." will repeat the indentation of the previously selected text if it was the newest edit of the text. This does not reselect the text, but does the job just as well.

Tags:

Vim