Friday, August 14, 2015

C comment block indentation woes

I've been merrily using vim for the past fifteen years and loving the cindent/cinoptions functionality, but alas I have finally met my match when trying to auto indent some c block comments according to a new company's coding standard.

The behaviour I'm after is ludicrously simple:

/*
Comment block indented
by shiftwidth
*/

The behaviour I'm getting is:

/*
Comment block indented
by shiftwidth
*/

Try as I might, I can not get that closing */ to be aligned with the opening /*. I don't care about when typing (the default 'comments' rules are fine), but when I use the = command, the */ stubbornly lines with the rest of the comment block.

Given that there isn't an option for aligning the closing */ indicated in the cino section of the manual, I'm guessing that there probably isn't a way of doing it. I am an eternal optimist though, so I'm hoping some bright spark will be able to help out. Essentially, the option I'm looking for is the comment equivalent of cino-}

For reference, the relevant settings I have are:

:verbose set ft? cin? cino? com? si? ai? inde?

filetype=c
Last set from /usr/share/vim/vim74/filetype.vim
cindent
cinoptions={sn-s>2s^-scs
comments=sO:* -,mO:* ,exO:*/,s1:/*,mb:*,ex:*/,://
Last set from /usr/share/vim/vim74/ftplugin/c.vim
nosmartindent
noautoindent
indentexpr=

Thanks for any help you can offer, even a "Can't be done" would help.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment