Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I like the smart auto-indenting that VIM does when I start a new line, but I hate what it reformats the line I left. I'm looking for a way to turn this off.

Simple example. Say I have this HTML:

<!-- some multiline
     comment -->
<div id="foo" style="bar" class="baz">

If I put the cursor before the style tag and hit ENTER it reformats to:

<!-- some multiline
     comment -->
     <div id="foo"
       style="bar" class="baz">

Which is absolutely not what I want.

This frustrates me every single time I work on HTML files, as I'll start the line exactly where I want it and Vim will move it when I hit ENTER to go to the next line.

I still want it to auto-indent the new line (not always right on the first newline but that's easy to fix, and the rest all line up properly), but I never want it to change the line I was leaving.

share|improve this question
1  
Vim's behavior depends largely on what you have put in your ~/.vimrc. Please, add it to your question. Also, what is the output of :verbose set fo when you are editing an HTML file? –  romainl Jul 12 '13 at 6:35
    
formatoptions=tcq Last set from /usr/share/vim/vim73/ftplugin.vim –  Herms Jul 12 '13 at 13:07
    
My vimrc is rather complicated as I'm pulling in a number of other files (place I work provides a lot of stuff to automatically match style and such, though it doesn't seem to be doing so for html files). It's not really feasible to post everything it's triggering. –  Herms Jul 12 '13 at 13:13
    
I cannot reproduce it in my config, even messing with various settings like g:html_indent_inctags and 'indentkeys' (see :help html-indent and :help 'indentkeys' and :help indentkeys-format). I think you're going to need to try removing bits of your config a little at a time until you find the culprit. I get no re-indentation of the previous line when I insert a newline in insert mode before the style attribute. –  Ben Sep 15 '13 at 17:28

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.