2

Is there an existing EMACS command to select a block comment? That is, I have

/**
 * A Comment
 */

I want to set the mark ahead of the /** and set the point after */.

I realize there are several ways it can be done, but I don't want to write code if there already is code.

3
  • Yeah this would be the most useful thing in the world.
    – NNN
    Commented Nov 27, 2017 at 16:10
  • 1
    There is er/mark-comment in the library expand-region.el.
    – Tobias
    Commented Nov 27, 2017 at 16:11
  • I knew someone had to have done it. Make this an answer so I can checkmark it. Commented Nov 27, 2017 at 16:16

1 Answer 1

1

You can install the package expand-region via package-install. There you find er/mark-comment in er-basic-expansions.el.

It is suggested to bind just er/expand-region to some suitable key sequence.

If you hit this key sequence region is expanded to the current word at first. The region is expanded further and further if you press repeatedly return. If you start with point in a comment one of the expansions is the current comment.

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.