How do I move the cursor to the opposite corner of a blockwise visual selection?
Answer
O (in blockwise visual mode)
Explanation
In blockwise Visual mode (<C-v>), pressing O moves the cursor to the diagonally opposite corner of the rectangle. This lets you extend or shrink the block in both dimensions without having to restart the selection.
How it works
In a blockwise selection, the rectangle has four corners. Two motions control which corner is "active" (where the cursor sits and where movement extends the block):
o— toggle between the current line's two corners (left ↔ right on the same row end)O— toggle between the diagonally opposite corners (top-left ↔ bottom-right)
By alternating o and O, you can move the cursor to any of the four corners, letting you expand or contract the block in any direction from any starting point.
Example
Start a block selection at the top-left of a word:
|foo bar
baz qux
Press <C-v>2j$ to extend to the bottom-right. The cursor is now at the bottom-right corner. Press O and the cursor jumps to the top-right corner. Press O again to return to the bottom-right.
From the top-right corner, pressing o moves to the top-left, letting you shrink the left edge of the block.
Tips
oworks the same way in character-wise and line-wise Visual mode (toggles start/end of selection)Ois only meaningful in blockwise (<C-v>) mode- This is invaluable when you realize your block selection needs to start or end at a different edge after already extending it