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

How do I adjust the width of a visual block selection without restarting it?

Answer

O (visual block mode)

Explanation

In visual block mode (<C-v>), pressing O (uppercase) moves your cursor to the other end of the current line — letting you expand or contract the block's horizontal extent without losing your selection. Combined with o (lowercase), which jumps to the diagonally opposite corner, these two keys give you full control over any corner of the block.

How it works

  • <C-v> — enter Visual Block mode
  • o — move cursor to the diagonally opposite corner (changes both line and column)
  • O — move cursor to the other end of the current line (changes only column, keeps current row)

This is especially useful when you realize after starting a block selection that you need to widen or narrow it, or when you started from the wrong side of a column.

Example

You're selecting a block over three lines and want to adjust the right edge:

foo = 1;
bar = 2;
baz = 3;

Start with <C-v>jj to select three rows, cursor on f. Press O to jump the cursor to the right end of the current line (column of f to same line, other side). Now extend rightward with e or $ to include the full assignment — no need to restart.

Tips

  • Use o to toggle between all four corners of the block for precise selection tuning
  • Works the same way in :help visual-block: o goes to opposite corner, O goes to opposite side of same line
  • After adjusting, you can apply any operator: d, c, I, A, ~, >

Next

How do I match a pattern only when it is preceded or followed by another pattern, without including that context in the match?