开发者

vim indentation correction not working correctly

开发者 https://www.devze.com 2023-01-12 03:03 出处:网络
I\'m using vim to edit files that use a programming language where the end of line is not marked with ;. This causes problems when I try to fix indentation in vim. If I put a ; at the end then vim is

I'm using vim to edit files that use a programming language where the end of line is not marked with ;. This causes problems when I try to fix indentation in vim. If I put a ; at the end then vim is able to correctly fix the indentation, but since this programming language doesn't have a ; at the end of a statement the indentation isn't correct after vim tries to fix it.

Here is the code correctly formatted:

if imageFound("foo.bmp")
{
    clickButton("button1.bmp")
    clickButton("button2.bmp")
}

If I do =G then in will turn into this, which is incorrectly formatted:

if imageFound("foo.bmp")
{
    clickButton("button1.bmp")
        clickButton("button2.bmp")
}

However, if I put a ; at the end of one of the lines the line unde开发者_如何学编程rneath it will be correctly formatted.

if imageFound("foo.bmp")
{
    clickButton("button1.bmp");
    clickButton("button2.bmp")
}

How can I make vim correctly fix the formatting without having to put a ; at the end of lines?


:set cindent cinoptions=+0.

0

精彩评论

暂无评论...
验证码 换一张
取 消