How do you use indent in vim for web development?

Posted by Somebody still uses you MS-DOS on Stack Overflow See other posts from Stack Overflow or by Somebody still uses you MS-DOS
Published on 2010-05-10T16:10:14Z Indexed on 2010/05/10 16:24 UTC
Read the original article Hit count: 197

Filed under:
|
|

I'm starting to use Linux and Vim at work. I'm starting to read vims documentation and creating my own .vimrc file and such.

I'm a web developer working with HTML, XML, CSS, JS, Python, PHP, ZPT, DTML and SQL.

I would like to have an indent feature like this one: for each language/set, a corresponding indent solution.

So, in js, writing function test(){|} would turn in

function test(){
    |
}

If php, writing <?php function test(){|}:

<?php
    function test(){
        |
    }
<?php>

...and such. Writing a function definition in Python, and then creating a for loop sentece, it would automatically create an indent.

I'm starting with autoindent, smartindent, cindent but I'm a little confused about their differences.

How do the indent in vim works? Am I supposed to download plugins for each language? Is the behavior I described possible with already existing plugins you're used to or do I have to create it?

I keep seeing people using Vim and I'm trying to do this as well since the machine I'm using is too limited, but I'm afraid I won't be able to have a decent auto indenting solution in it.

(I have used autoindenting in a little small project in Visual Studio, and really liked their approach. Is there a plugin for that?)

© Stack Overflow or respective owner

Related posts about vim

Related posts about indentation