Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VIM automatic indent of LaTeX files bad

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!

like image 541
Bernicc Avatar asked Oct 02 '12 15:10

Bernicc


People also ask

How do I turn off Autoindent in Vim?

To turn off autoindent when you paste code, there's a special "paste" mode. Then paste your code. Note that the text in the tooltip now says -- INSERT (paste) -- . After you pasted your code, turn off the paste-mode, so that auto-indenting when you type works correctly again.

Does vim have auto indent?

How to Turn On Auto Indent in Vim. To automatically indent when editing a file in Vim, enable the auto indenting feature using the :set autoindent flag in command mode: Press Enter, and this will auto-indent the file you are currently editing.

How do I change the indentation in Vim?

Start in the top of a file (to get there, press gg anywhere in the file.). Then press =G , and Vim will fix the indentation in the whole file. If you don't start in the beginning of the file, it will fix indentation from current line to the bottom of file.

What is smart indent in vim?

autoindent essentially tells vim to apply the indentation of the current line to the next (created by pressing enter in insert mode or with O or o in normal mode. smartindent reacts to the syntax/style of the code you are editing (especially for C). When having it on you also should have autoindent on.


1 Answers

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/

like image 150
Santiago Rebella Avatar answered Sep 28 '22 08:09

Santiago Rebella