16
votes

I want to indent with gg=G some LaTeX files. But I get a bad indent.

\title{                                                                         
\rule{\textwidth}{1pt}\\[0.5em] \huge                                           
\textsc{My headline           
\rule{\textwidth}{1pt}}                                                         
}

What I get:

\title{
    \rule{\textwidth}{1pt}\\[0.5em] \huge
        \textsc{My headline
            \rule{\textwidth}{1pt}}
}

What I want (or similar):

\title{
    \rule{\textwidth}{1pt}\\[0.5em] \huge
    \textsc{My headline
    \rule{\textwidth}{1pt}}
}

Is this normal? Wrong config file? Flags? AddOns? Can anybody help? Thank you!

2
The indent wich you are getting with vim is correct because \rule is indide \textsc which is inside \hugerbernabe
You could also try the latexindent.plx Perl script on your existing LaTeX files.Werner

2 Answers

5
votes

I allways had a bad indentation with VIM, even after trying many stuff. if it helps I just turn it off and indent manual. there is the autoindent, the smartindent, and not sure if any other "geek" indent type setting just if you would like to experimentate combinations of on off

http://vim.wikia.com/wiki/How_to_stop_auto_indenting

also maybe trying with the :set paste could be what you need.

http://ayaz.wordpress.com/2008/06/21/paste-mode-pasting-text-and-indenting-it-in-vim/

0
votes

The default indenting for .tex files is set for plain TeX, you can set it to LaTeX adding the following line to .vimrc:

 let g:tex_flavor='latex'