Reputation: 101
Say the cursor is at the asterisk:
void foo(int n) {
int i;
// the cursor is here: *
for(i=0; i<n; i++) {
bar(i);
}
}
What's the easiest way to perform an operator until the end of the function? If I run dΩ
, when Ω
is this operator, I'd expect to see:
void foo(int n) {
int i;
// the cursor is here:*
}
That is, everything from that point to the end of the function is deleted. I know about di{
, but that would delete the entire function.
Upvotes: 0
Views: 314
Reputation: 32936
For C, Vim already provide ways to do that natively.
In C++, there are corner cases with functions defined within a class definitions - in these cases, the function definition is not 0-indented, and Vim doesn't know how to handle the detection function boundaries.
Some scripting is required. On vi.SE, I did describe a solution that I've integrated through 2 plugins I'm maintaining (lh-dev + lh-tags).
Upvotes: 2
Reputation: 15091
An alternative is to use a RegEx:
d/^}<CR>
That is: delete until the line starting with "}".
Upvotes: 1