If the cursor is at
the quick brown fox
and we type
d/brown, we delete
the quick . Is there a way to extend this such that the searched term is deleted too? (Such that only
Searches are exclusive by default. That means that you only delete up to the start of the matched text which is where the cursor would end up. We need some way to force the match/cursor to fall at a point that encompasses the whole pattern string. One way is to add the offset flag
With no numerical value specified after
/e the offset is effectively 0 (from the flag's position) and the cursor falls on the last character of
brown. Thus everything up to and including that character gets deleted. (Whereas, for example,
/e+2 (or more) would put the cursor past the pattern.)
Take a look at
:h search-offset for details about
/e and several other flags with related functions.
Alternatively, you can use the more familiar
\zs to do accomplish the same thing:
This pattern atom "sets the start of the match" to its location. Since everything up to the start of the match is deleted this also has the the result we want.
:h /\zs for details.