Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vim: delete to character, non-inclusive

Tags:

vim

Suppose I'm in a certain line position in vim and I want to delete up to a certain character, say a semicolon. I would do df; except it would also delete the semicolon. Is there a command that will do the same thing but will not include the character I'm searching for?

like image 331
Amir Rachum Avatar asked Feb 25 '10 08:02

Amir Rachum


2 Answers

Yes, dt;. From the Vim docs:

t{char}

Till before [count]'th occurrence of {char} to the right. The cursor is placed on the character left of {char} |inclusive|. {char} can be entered like with the |f| command.

like image 93
Michał Marczyk Avatar answered Sep 17 '22 13:09

Michał Marczyk


To add to what Michal said, you can also use T and F to do the same thing backwards.

Also ; will repeat the last t,T,f or F motion, and ' will repeat it in the opposite direction.

like image 38
Dave Kirby Avatar answered Sep 21 '22 13:09

Dave Kirby