I've remapped Ctrl-j to next-line with (global-set-key "\C-j" 'next-line) but this doesn't work under TeX mode where Ctrl-j "insert two hard returns (standard end of paragraph) and check syntax of paragraph". Is there a work around?


That's because tex-mode redefines C-j and the mode's keymap takes precedence over the global keymap. If you plan on redefining common keys like this then I suggest you create a minor-mode with your definitions and then they will take precedence over the major mode's keymap.

The other thing that you can do is unbind the key in tex-mode, but then you'll have to do the same for every other mode that binds C-j. You should definitely look at this question on how to globally override keys.

| improve this answer | |

can you reproduce the problem without loading the init file? emacs -q or emacs --no-init-file should run emacs without the config file. Repeat your actions to see whether it solves it.

And does this question help? You could do the remapping in the local mode as suggested here; you just have to change it to your function and tex-mode.


| improve this answer | |
  • well, then I lose my remapped keystrokes – manuzhang Feb 15 '12 at 8:30
  • err..after you start a clean emacs, you eval you remapping in the scratch buffer and then see what happens in tex mode. Sorry, I wasn't clear about that part – Sivaram Feb 15 '12 at 8:56

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.