3

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?

2 Answers 2

5

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.

1
1

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.

https://stackoverflow.com/questions/9082680/how-to-disable-c-j-in-emacs-major-mode

2
  • well, then I lose my remapped keystrokes
    – manuzhang
    Feb 15, 2012 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, 2012 at 8:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .