maddingl
maddingl

Reputation: 207

VIM - do not leave visual mode after doing something with it

In vim, when I am in visual mode and do something with it, like e.g. indenting some lines, after the operation is applied, I am thrown back into normal mode. How can I change this behavior so that I stay in visual mode until I press Esc? I would like to be able to e.g. indent the lines once more immediately after.

Upvotes: 4

Views: 215

Answers (1)

Harish
Harish

Reputation: 1441

I am not sure if there's a way to change the behavior for all of the visual mode. I find the indentation behavior odd too and I have a visual mode mapping in my .vimrc for fixing this

vnoremap > >gv
vnoremap < <gv

Explanation

vnoremap -> non-recursively remap in visual mode

gv -> selects the previously selected visual selection

So, creating a visual mode mapping for the keystoke(s) you're using and suffixing it with gv would make sure you stay in the visual mode. Maybe not the best way, but it works, interested to find if there are better ways.

Upvotes: 7

Related Questions