tags:

views:

58

answers:

2

I'm trying to use vim to edit source code for AutoHotkey.

This is how the source code looks when correctly formatted:

if foo
{
    if bar = 1
        callFunc1()
    if bar = 2
        callFunc2() 
    if bar = 3
        callFunc3()
}

If I do =G, then this is what vim changes it to:

if foo
{
    if bar = 1
        callFunc1()
        if bar = 2
            callFunc2() 
            if bar = 3
                callFunc3()
}

I had other formatting problems with this source code that was solved by using :set cindent cinoptions=+0, but that does not solve this problem.

A: 

cindent is generally for C... There are lot of vim extensions for various programming languages, google for them. They often introduce proper syntax indentation.

skalee
A: 

If there's no indent file for this kind of script, you can use the indentAnything script.

As stated :

The IndentAnything plugin is intended to make it easier to write new indentation scripts and/or supplement existing ones. It makes the assumption that all indentable languages have similar characteristics:

  • blocks of code or text over multiple lines
  • continuation lines
  • comments
Drasill