How do I force a motion to act blockwise, linewise, or characterwise?
Answer
d<C-v>2j
Explanation
Vim lets you override the natural type of any motion by pressing v, V, or <C-v> between the operator and the motion. This forces the operation to be characterwise, linewise, or blockwise respectively.
How it works
vforces characterwise (even if the motion is normally linewise)Vforces linewise (even if the motion is normally characterwise)<C-v>forces blockwise (column-based operation)
Examples
" dj normally deletes 2 full lines (linewise)
" d<C-v>j deletes a 1-column x 2-row block instead
d<C-v>j
" yV} yanks to end of paragraph as full lines
yV}
" dv} deletes to end of paragraph characterwise
dv}
Practical use case
If you want to delete a rectangular column of text without entering visual block mode first:
d<C-v>3j3l
This deletes a 4-row by 4-column block starting from the cursor.
Tips
- This is one of Vim's least-known features but extremely powerful for precision editing
- Works with any operator:
c,y,d,gq, etc. - Documented under
:help forced-motion