Assuming a line such as:
grep -ir "$@" * | grep -v "/.svn/" | grep -v "/inc/help/" | head -n 100
If the cursor is at the first
| and I want to delete until
head, how could I do that with t? I know that I could
v/hea to select until
hea but when I then delete the text I will have removed the leading
head as well. I could just
h back a character, but this is now a chain of workarounds. It works, but I would like to know if there is a better way.
Is there any way to have
t depend on two or more characters instead of a single character?
:vnoremap / //b-1<left><left><left><left>
When you type
v to visually select a region, then type
/ to begin the search for the end of the region, Vim will enter
into the command line with the cursor over the second
/. Then you type the 2 or more characters that you wish to terminate the region with and hit Enter. The
b-1 tells Vim to search for that pattern and put the cursor one character before (
beginning of the match. See
You don't have to map
/. You could map
t or some other character instead.
if you can do it interactively you may try it with easymotion-plugin:
d;;fh -> will grey out all text and mark all
h letters red but substitute them by
a,b,c,… and then you may hit
b to delete to the second
I know this description is a bit cryptic - have a look at a youtube-video
Ps.: I forgot to mention
; is my leader key
d2fh will do it in your example.
I appreciate all the great answers, and I've learned a bit from them. However, each one required me to count or calculate the offending characters. Even my own question does require me to already know that there exist offending characters!
Thus, the best solution that I have found is to simply
dth and if that doesn't delete up to the character that I need, then I can just press
. to do it again.
t accepts only one character. I'd do