cartbeforehorse
cartbeforehorse

Reputation: 3487

Vim: delete to next character, when next character is not on same line

I'm sure that I'm going to get ridiculed for asking a duplicate question; someone must have asked the question before! But in an hour of searching I haven't found it. I must be searching for the wrong thing.

In Vi (or Vim) I am able to delete all characters up to the } character through the key sequence dt} (or df} if I want to remove the bracket as well).

However, this only works if the } character is on the current line. What I want to do is to delete everything up to the next } even if it's first occurrence is on a subsequent line.

I'm thinking something like d/} (where the slash /}<enter> in any other context, would take me to the next occurrence of }). For obvious reasons, this doesn't work, but I hope the intention is clear.

== EDIT ==

Okay okay okay... sorry. You're all right, it does work (on my clean-install machine). might be some messed-up mapping in a config file, but it's not working on my other one.

Hang head in shame

Upvotes: 17

Views: 3275

Answers (3)

Raimondi
Raimondi

Reputation: 5303

This plugin should save you some keystrokes. It extends the functionality of fFtT,; so they work across lines.

Upvotes: 3

Birei
Birei

Reputation: 36282

If the character is } or { placed at the beginning of the line, one way could be using Text object motions, so a command like d]] could be useful too.

Upvotes: 1

romainl
romainl

Reputation: 196886

d/}<cr> works. It's the canonical way to delete until the next } that's not on the same line. By the way, d?{<cr> does the same but in the opposite direction.

Upvotes: 16

Related Questions