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.

Are there useful navigation shortcuts in emacs when editing a TeX source? For example jump to the beginning/end of section, or similar thing for environment, etc.

C-v and M-v are two coarse, and I am looking for smarter navigation tips. Something in the spirit of C-M f and C-M b which jump over balanced braces.

share|improve this question
    
There is the C-M-a and C-M-e keys which jump to beginning and end of current environment? But only by using AucTeX. –  zeroth Aug 7 '12 at 10:39
add comment

2 Answers

up vote 8 down vote accepted

If you use AucTeX, with outline minor mode turned on, you get a series of useful key-bindings, including (C- = Ctrl-):

C-c @ C-n   Move to next heading (at any level)
C-c @ C-p   Move to previous heading (at any level)
C-c @ C-f   Move Forward to next heading at the same level
C-c @ C-b   Move Backward to previous heading at the same level

A quick look at the AucTeX Reference Card will get you started.

share|improve this answer
    
@Michael: Thanks! And to Percusse... –  Brent.Longborough Aug 7 '12 at 12:21
add comment

The answer lies in Emacs for navigating around a document.

For specific needs in Tex, I would make a macro.

For next section (which is same as ending of previous section):

    F3          % start recording
    C-s section % search forward for any type of "section"; \sec for specifically \section
    RETURN      % stop there
    F4          % end recording  
    % you could choose to search for \begin{, or for anything.
    Reusing the F4 will replay the macro, so you can test it.

Save it for later use " C-x C-k n " then giving the name, and using Return.

M-x insert-kbd-macro RETURN the-given-name RETURN will paste the code into your document.

If you then put the code into your .emacs file, followed by

    (eval-after-load 'latex
                     '(define-key LaTeX-mode-map (kbd "C-c C-z") 'the-given-name))

The keybind will only load when you enter latex mode. (First restart/reload the .emacs) This way C-c C-z would go to the next section (or other specified search)

share|improve this answer
    
It might seem like a lot of work, but once you get the hang of it you can make new commands within the minute. –  Dualinity Aug 7 '12 at 11:14
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.