When I have a commented line in my TeX file, eg

some text that is not commented
|%% here is a comment
followed by more uncommented text

(the | represents point), and I hit RET, point is moved past the %% and into the comment, like so:

some text that is not commented

%% |here is a comment
followed by more uncommented text

This seems very strange, and to me it is undesirable. For instance, if I want to add another newline before the commented line, I have to backtrack to the beginning of the line first. I want point to stay in front of the % characters.

How can I disable this annoying behavior?

  • That is odd. I'm not sure how to fix it, but in the meantime the command C-o will open a new line at point, which does what you want RET to do in this case.
    – Tyler
    Oct 10 '17 at 20:41
  • I know about C-o (which calls the function open-line), but that leaves point on the current line, that is, it inserts the newline after point, not before it. I just want RET to act like it used to and I don't understand why this behavior is now the default. It is truly bizarre.
    – MTS
    Oct 10 '17 at 20:47
  • Do you use additional minor modes or packages which might hook into the key bindings and alter them? To me, it seems that another package has simply altered the way comments are handled, by enforcing that the pointer is moved behind the comment prefix.
    – user17303
    Oct 22 '17 at 19:54
  • What is the value of the variable electric-indent-mode in your .tex file where you observe this? If t, please try M-x electric-indent-local-mode RET and try it again. Nov 18 '17 at 13:52
  • 1
    (setq LaTeX-syntactic-comments nil) solved it for me (see this manual page). Mar 16 '18 at 22:31

Add (setq LaTeX-syntactic-comments nil) to your init.el to disable the option LaTeX-syntactic-comments.

According to the manual:

User Option: LaTeX-syntactic-comments
If non-nil comments will be filled and indented according to LaTeX syntax. Otherwise they will be filled like normal text.

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.