3

The % command is quite nice, and I use it to copy/delete whole loops, functions and classes.

In c++ though, you need to add a ; after your class declaration, so trying to motion over a whole class won't work with the % command.

Is there a way to get the command to carry on the motion? I guess just adding a f; will be enough, but I'm not sure how.

1 Answer 1

5

You can force a motion to be linewise; then, the % would include the full last line, including the trailing ;, for example yV%. Unfortunately, if you use the matchit plugin, that doesn't work any more, but you can instead use visual mode: V%y (interestingly, this is the reverse of the above!)

Alternatively, you could define a custom motion for that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.