I'd like to extends this function to work as usual in most cases but if current line starts with * then it should indent and then insert *. Particularly i want to use it in multi line comments, i.e:

  * multiline comment

So when i press Ret, while writing a comment, it would add *.

  • This doesn't answer your question, but if you just write one long line and then hit M-q the comment will be broken into several lines in the appropriate way.
    – Malabarba
    Nov 12, 2014 at 16:46

1 Answer 1


I think the command you want to use is comment-indent-new-line which is normally bound to M-j.

  • Unfortunately it doesn't insert *, is there any way to fix this?
    – 4lex1v
    Nov 12, 2014 at 15:32
  • It does when I test it with emacs -Q ~/tmp/foo.c and type /** RET * foo M-j so you'll need to give more details about your setup to figure out why it doesn't work for you.
    – Stefan
    Nov 12, 2014 at 17:32
  • Probably i should, it works for C, but i'm interested in scala-mode2
    – 4lex1v
    Nov 12, 2014 at 17:37
  • Then you should report the problem to the scala-mode2 maintainers.
    – Stefan
    Nov 12, 2014 at 19:08

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.