df: - delete to the next colon
2f, - move cursor forward to the 2nd comma
I find cause to use f fairly regularly.
df: - delete to the next colon
2f, - move cursor forward to the 2nd comma
I find cause to use f fairly regularly.
ct) (change to) will change everything from the cursor up to, but not including the paren.
But if you're trying to change everything in parens, you can simply use: ci(, regardless of where your cursor is as long as it's somewhere in a matched set. ci{, ci[, etc... also work. I find it pretty useful when working with code that uses a lot of those.
One is when inside a parenthesis, and wanting to really delete till the closing parenthesis. But that would leave an unbalanced open paren. So in this case, I use ct) most of the times.
The other is when the cursor is before the opening parenthesis, and I want to delete the whole block. In that case, I found c% to be easier to me. The advantage being that it works with other delimiters ({[]}) handles nesting better, and it's multiline friendly.
If instead of c%, we speak about d%, another plus is that dot (.) will repeat the generic command, so
if (is_foo()) {
return 1;
}
can be cleared with `d%.` from the beginning of the first line.The % approach works only on one direction.
if funca(funcb(red, green), funcc(blue, yellow)) {
^
If you are where the arrow is, `c])` will change the second argument. If you were on the comma before it, `d])` will remove all but the first argument.Quite helpful if you have multiple of the same character and you want to go beyond the first one without needing to count.
Muscle memory is a weird thing.