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

How do I force a normally linewise motion to operate characterwise when combined with an operator?

Answer

dv{motion}

Explanation

In operator-pending mode — after typing an operator like d, y, or c but before the motion — you can press v, V, or <C-v> to override the motion type to characterwise, linewise, or blockwise respectively. The v override forces the operation to work on individual characters rather than whole lines, giving you finer control over exactly what is deleted or yanked.

How it works

  • d — enter operator-pending mode with the delete operator
  • v — override the motion type to characterwise (excludes trailing newlines)
  • {motion} — any motion: j, }, G, %, etc.

This technique works with any operator: d, y, c, >, =, etc.

Example

Given this two-line text with cursor at the start of line1:

line1
line2
  • dj (linewise) deletes both complete lines — nothing remains
  • dvj (forced characterwise) deletes from the cursor to the same column on the next line — leaving line2 intact from that column onward

Another practical use: yv} yanks to end of paragraph without including the trailing blank line, whereas y} would include it.

Tips

  • dV{motion} forces linewise — useful when a characterwise text object (like iw) should grab whole lines
  • d<C-v>{motion} forces blockwise — rarely needed manually but powerful in scripts
  • The override affects only the type, not the motion endpoint itself
  • In visual mode, v, V, and <C-v> switch between the three visual sub-modes instead

Next

How do I enable matchit so % jumps between if/else/end style pairs?