views:

755

answers:

3

Vim 7.0.237 is driving me nuts with indentexpr=HtmlIndentGet(v:lnum). When I edit JavaScript in a <script> tag indented to match the surrounding html and press enter, it moves the previous line to column 0. When I autoindent the whole file the script moves back to the right.

Where is vim's non-annoying JavaScript-in-HTML/XHTML indent?

+1  A: 

Have you tried this plugin?

innaM
Unfulfilling. I get a couple of decently indented function calls followed by a left-aligned var. Some people will find it pleasant that the plugin doesn't indent for <html> <head> or <body>, so the interesting structure of the document is less likely to be too far to the right.
joeforker
Then why accept this answer?
innaM
A: 

Personally I toggle between :set ai and :set noai, but might be too tedious for you.

dlamblin
A: 

Here is similar question with accepted answer with links to two vim plugins:

  1. html improved indentation : A better indentation for HTML and embedded javascript mentioned by Manni.
  2. OOP javascript indentation : This indentation script for OOP javascript (especially for EXTJS) .

One of them solved my problems with JavaScript scripts indention problems.

Grzegorz Gierlik