vim-ninja-feet icon indicating copy to clipboard operation
vim-ninja-feet copied to clipboard

Strike from the cursor to either end of a text object

ninja-feet.vim

In Practical Vim by Drew Neil, a cute illustration outlines the difference between Vim's standard motions and text objects. In short, we see a ninja kicking in one direction (a motion) compared to a ninja kicking in two directions (a text object).

Ninja with feet

While Vim has a great number of wonderful text objects, and plugins can add even more, there is no general way to operate from the cursor to the beginning or end of those text objects.

Well, now there is. ninja-feet.vim lets you do so by putting [ or ] between the operator and the text object. For example, d]i) deletes from the cursor to the end of the current parenthetical term. c[ip changes from the cursor to the beginning of the paragraph.

You can also jump into Insert mode at the beginning or end of a text object (technically, any motion) with z[ and z].