Question

I used to start all my comments from column 60.

Is there a trick in Emacs with which for the current line, anything after (and including) // is pushed to column 60?

Example

cmp A, B // comparing against a reference

becomes

cmp A, B <-- extra spaces added until column 60 ---> // comparing against a reference
Was it helpful?

Solution

Set comment-column to 60, and hit M-;.

Note that M-; runs comment-dwim which tries to do what you mean. Notably, if the region is active, it will comment out the entire region. If this gets in your way, the command that does what you ask for above is comment-indent, which you could bind to a suitable key.

OTHER TIPS

Set the comment-column as said by legoscia, select a region and call M-x align-regexp RET // RET. That will align your comments on the same column.

For the doc: C-h f align-regexp.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top