Spencer Collyer wrote:
> Hi,
> 
> When I'm writing C++ code, if I have a long comma-separated list of
> items (like initializer parameters or function arguments) I like to lay
> them out so that the comma is the first non-whitespace character on the
> line, like so:
> 
>       foo( param1
>            , param2
>            , param3
>            , param4
>            , param5
>            );
> 
> This is a technique I picked up many years ago, and it seems to be
> becoming more common, certainly in the programming groups I've worked
> with.
> 
> The problem is, I've not been able to work out how to get this to
> layout properly with VIM.
> 
> I have the following two lines in my .vimrc:
> 
> set cindent
> set cinoptions=g0,+0,t0,(0
> 
> But using these I get the following layout:
> 
>       foo( param1
>              , param2
>              , param3
>              , param4
>              , param5
>            );
> 
> What I'd like is to get the commas lined up below the '('. A similar
> thing happens for initializer lists - the commas line up below the
> start of the first identifier, not the ':' that introduces the
> initializer list.
> 
> Is this possible to do with current Vim? If not, can I put in a request
> to have it put on the TODO list?
> 
> Thanks for your attention
> 
> Spencer
> 
> 

It resembles what I do for CSS; here is an "actual" example (from my Firefox
userChrome.css):

.tabbrowser-tabs *|tab
  { height:             18px            !important
  ; min-width:          16px            !important
  ; margin:             0px             !important
  ; border-width:       1px             !important
  ; border-color:       black           !important
  ; border-style:       solid           !important
  ; -moz-border-radius: 2px 2px 0px 0px !important
  ; border-collapse:    collapse        !important
  ; padding:            0px             !important
  ; text-align:         left            !important
  }

but I'm doing it with just

        :filetype indent off
        :set autoindent smartindent nocindent

(I don't trust autoindent scripts anyway). If these settings aren't powerful
enough for you, maybe you should write an indent-function for 'indentexpr'
(q.v.) ?


Best regards,
Tony.

Reply via email to