How do I adjust a visual selection from the other end without starting over?
Answer
o
Explanation
While in visual mode, pressing o moves the cursor to the opposite end of the selection. This lets you extend or shrink the selection from the other side without cancelling and restarting.
How it works
ostands for "other end" of the visual selection- The selection anchor stays fixed; only the free end (cursor) moves
- Works in all visual modes: character (
v), line (V), and block (<C-v>) - In block visual mode,
Omoves to the other corner of the same row, whileomoves diagonally to the opposite corner
Example
Suppose you start a selection with v on quick and extend it forward:
The [quick brown] fox
^cursor here
You realize you included too much. Press o to jump the cursor back to the start of the selection:
The [quick brown] fox
^cursor now at anchor end
Now you can press b or h to shrink from the left side.
Tips
- Pair with
gvto re-enter the last visual selection and then useoto fine-tune it - In linewise visual mode (
V),oswaps between the first and last selected line - Useful after accidental over-selection when using text-object motions