0

I have a problem with indentation after:

cout << "...." ....;

lines in c++-mode. Expected cursor position after pressing Enter is the next line and column is right under cout.

But as you may see at the screenshot, there are many columns skipped on the next line after cout:

enter image description here

Any ideas how to fix this?

Thank you.

UPD

So I've found where the problem is. Such indentation because of:

(setq electric-pair-pairs '(
                            ...
                            ...
                            (?< . ?>)
                            ...
                            ...)))

If I comment (?< . ?>), everything is ok

  • Perhaps you have an add-on package interfering with normal indentation. What version of emacs? With cursor on the next line (as shown in the picture), what does C-c C-s show? – InHarmsWay Sep 13 '17 at 10:23
  • endl has no std:: so intellisence compiler probably failed to "compile" the previos line - so it does not know where properly put the cursor on the next line... – Artemy Vysotsky Sep 13 '17 at 11:54
  • What version of emacs are you running? You can execute (message emacs-version) in scratch buffer. – Felipe Lema Sep 13 '17 at 13:34
  • As @InHarmsWay suggests, it looks like another package is interfering. I ran emacs -Q, evaluated your settings, edited the same code and not getting the indentation you describe. – Felipe Lema Sep 13 '17 at 14:28
  • I have the same problem with emacs 25.3.1. I have electric setup but don't have the (?< . ?>) line, so the fix proposed in the early post doesn't work. This happens after a while and quite randomly, on big-ish files, so I don't have a minimal example. It works when I restart emacs (revert-buffer won't do it). C-c C-s shows Syntactic analysis: ((template-args-cont 16211 16222)). Any clue? – Pierre Lasorak Jan 3 at 16:57

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.