vim – Vim tip 34534

I’ve been looking for a way to delete up to a character, but not including the character from within vim, and I finally figured out how to do it.
Lets say you have something like this:

If the cursor is at the beginning of the line, and we want to change the name of the array completely, we could type this:

This will delete all the way to the bracket. Unfortunately, it deletes the bracket.
So instead, this works nicely to NOT remove the character you type:

This will delete every character up until the bracket, but leave the bracket. How nice.
So what does this “t” movement key do exactly?
It simply moves the cursor to the character right before the one specified, and it stays in “normal” mode.
If you wanted to immediately type after deleting the characters, you would use the following:

Which will delete the text, leave the “[” character, but change to insert mode right before the “[” character.

Another thing you can do is type:

de

Leave a Reply

You must be logged in to post a comment.