Reputation: 2330
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?
Upvotes: 12
Views: 4988
Reputation: 15715
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.
Upvotes: 22
Reputation: 161664
Try vim plugin Tabular
:
:Tabularize /\v[( )](int|$)
Tutorial: http://vimcasts.org/episodes/aligning-text-with-tabular-vim/
Upvotes: 6