On Thu, 25 Jan 2007 10:10:18 +0100, A.J.Mechelynck wrote:
> 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.

Thanks for the pointer Tony. Now I've looked at the help for
'indentexpr' and realise I can call cindent() so I don't lose the
'cindent' functionality for all other lines, I may actually have a go
at this. It'll be a good introduction to programming Vim for me (and is
better than the other option I was contemplating - patching the source
code to do what I want with an extra cinoption :) )

Spencer

-- 
<<< Eagles may soar, but weasels don't get sucked into jet engines >>>
7:06am up 80 days 15:44, 15 users, load average: 0.10, 0.07, 0.02
Registered Linux User #232457 | LFS ID 11703

Reply via email to