Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
add comment

migrated from stackoverflow.com Feb 15 '12 at 22:18

This question came from our site for professional and enthusiast programmers.

2 Answers

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.

share|improve this answer
1  
this page details the second option: xahlee.org/emacs/reclaim_keybindings.html . but as Ivan points out, with this method, you will have to do this for all modes, so creating a minor mode as described here: chemie.fu-berlin.de/chemnet/use/info/elisp/elisp_21.html#SEC305 –  Mortimer Feb 16 '12 at 8:20
add comment

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.

How to disable C-j in emacs major mode

share|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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.