7

Is there a way to change inside of a comment with Vim? I know you can change inside brackets and quotes with i] and i". For example, If you are on a quote you can press,

ci"my new textESC

And this will replace the text inside of the quote with the phrase "my new text", but how can I do the same thing with C comments which are enclosed with /* and */?

  • Maybe with the %? But you'd need to be at the start or the end of the comment. – Alexis Wilke Sep 7 '14 at 23:32
4

The Vim term for text that can be selected, yanked, deleted, and modified based on certain groupings of characters is text object (see :help text-objects). There's a comment-aware text object plugin called textobj-comment.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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