views:

280

answers:

2

I'm tired of writing comments that look like this

{
    # bla bla blabla bla blabla bla blabla
    # bla bla blabla bla blabla bla blabla bla blabla bla blabla bla bla
    # blaaa bla
}

I have to manually wrap the lines and take care of the # as well. How do emacs pros make the editor work for them?

+7  A: 

Selecting the comment and hitting M-q will usually reformat it.

M-q is generally mapped to fill-paragraph, c-fill-paragraph, or some other mode-specific variant.

Kristopher Johnson
+1 Assuming you are in the right mode, anyway. Also beware that many modes have tunable formatting parameters.
dmckee
Exactly what I would have written. +1.
Christian Madsen
+4  A: 

Use auto-fill-mode together with comment-auto-fill-only-comments (the latter is from newcomment.el).

Joe Casadonte
That is wonderful. I added the following to my .emacs. Works perfectly. Thank you!(require 'newcomment)(setq comment-auto-fill-only-comments 1)(setq-default auto-fill-function 'do-auto-fill)
Samuel Danielson