55

Sometimes I have selected a visual selection with, for example, Vjjjjj, only to realize later that I should have started the selection one line higher. However, pressing k simply decreases the lower range of the selection rather than moving the entire selection up one line.

Here's a visualization (ha, ha), where the bolded lines are the ones I have selected:

Do not select this line
Do not select this line
Select this line!        
Select this line!        <-- I pressed V here...
Select this line!
Select this line!
Select this line!
Select this line!        <-- ... and moved to here. But I should have started my
Do not select this line      selection one line higher!
Do not select this line

How can I extend a visual selection by moving its starting point in the other direction? If this is not possible, is there any way to add a mapping in my .vimrc that enables me to do so?

1 Answer 1

81

You can use the o command, from :help v_o:

Go to Other end of highlighted text: The current cursor position becomes the start of the highlighted text and the cursor is moved to the other end of the highlighted text. The highlighted area remains the same.

So when you have finished selecting the lines you want press o, the cursor will move to the beginning of the selection and you can select the line before by pressing k.

1
  • 15
    JAW DROPPED when i pressed o, :O May 25, 2018 at 14:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.