vimtricks.wiki Concise Vim tricks, one at a time.

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

  • o stands 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, O moves to the other corner of the same row, while o moves 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 gv to re-enter the last visual selection and then use o to fine-tune it
  • In linewise visual mode (V), o swaps between the first and last selected line
  • Useful after accidental over-selection when using text-object motions

Next

How do I run a substitution across multiple files using Vim's argument list?