Reputation: 72619
Suppose you want to delete a C function from its name up to and including the line with the closing curly:
int main (void) /* Cursor on this line. */
{
while (...) {
...
}
}
I have tried d/^}<CR>
but this does not delete the line with the closing curly. How can I have an inclusive find pattern delete? I must be missing something simple.
Edit You can assume the function's closing curly is at the start of a line and other curlies are never.
Upvotes: 3
Views: 602
Reputation: 31040
You could do jVaBokd
j
- move down a line
VaB
- visual line select on outer block
o
- move to the opposite end of the visual selection
k
- move up a line
d
- delete selection
Upvotes: 1
Reputation: 7946
Your command won't work on functions that have nested braces. I would delete to the first '{' with 0d]]
, followed by daB
to delete the block.
Details for new vimmers: The '0'
in the first command makes sure you're at the start of the line before editing the d
command. ']]'
is a motion that gets you to the next block, and 'aB'
is a selecting motion that selects the whole block, including nested blocks. So 0d]]daB
means delete from the start of the line to the next block, then delete the block.
Upvotes: 3
Reputation: 18290
I just did a quick search and found the offset syntax of the /
operator here.
d/^}/0
did the trick for me. It means "find the matching pattern, then select to the end of the 0th line after it" (i.e. the end of the line it is found on)
Upvotes: 6
Reputation: 36252
Use V][d
.
It means:
}
Upvotes: 5