user1252446
user1252446

Reputation:

VIM: how do I get close parenthesis aligned with block like close brace does?

in vim when you close the brace, it automatically aligned with the block head of the opening brace. like this:

f() {
    ...
}

how do I get closing parenthesis automatically moved and aligned the same way:

f (
   int i,
   ...
) {

At the moment, I can only get it aligned by use alignment command. e.g ==, without the command, it looks like this:

f (
    int i,
    ...
    ) {

i.e. an extra indent from where it is supposed to be aligned.

how do I fix this problem and make it work just like a closing brace?

Upvotes: 3

Views: 1147

Answers (1)

Alexander Batischev
Alexander Batischev

Reputation: 820

The answer depends on the value of 'indentexpr'.

If it's set (e.g. to GetJavaIndent()), you should look into fixing the corresponding function. No generic advice can be given here.

If 'indentexpr' is not set, you're using 'cindent', the behaviour of which can be affected with 'cinoptions'. The option you're looking for is m1. So just add this to your vimrc, and you should be set: set cinoptions=m1 (maybe wrap it into autocmd or something so that it will only affect specific filetypes.)

Upvotes: 2

Related Questions