Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vim indent: align function arguments

Tags:

vim

vim-plugin

The default alignment in vim (using "=") aligns my code as:

void my_loooong_function (int arg1,
        int arg2,
        int arg3
        )

However, I wish to align with all arguments starting at same line, as:

void my_loooong_function (int arg1,
                          int arg2,
                          int arg3
                         )

How can this be done?

like image 958
m.divya.mohan Avatar asked Aug 16 '12 09:08

m.divya.mohan


1 Answers

To make == work as you wish, you need to set cinoptions appropriately:

:set cino+=(0

Full documentation of the possible values can be found via :help cinoptions-values, and in particular :help cino-( to control the indentation inside unclosed parentheses.

The setting will also affect the autoindent behaviour (for example, when you enter a carriage return after opening a bracket).

This can, of course, be added to your vimrc or an ftplugin to automatically set this value for certain filetypes.

like image 181
Prince Goulash Avatar answered Sep 17 '22 17:09

Prince Goulash