[prev in list] [next in list] [prev in thread] [next in thread] 

List:       vim
Subject:    Re: Aligning operators when breaking C++-kode
From:       Antony Scriven <ads () metawire ! org>
Date:       2004-01-29 0:29:38
Message-ID: 20040129002938.GA7041 () openwire
[Download RAW message or body]

Jan 28, Charles E. Campbell, Jr. wrote:

 > Erlend Hamberg wrote:
 >
 > >On Wednesday 28 January 2004 16:51, Charles E. Campbell, Jr. wrote:
 > >
 > >
 > >>Please check out
 > >>http://vim.sourceforge.net/scripts/script.php?script_id=294 which
 > >>introduces <Align.vim> and <AlignMaps.vim>.
 > >>
 > >>
 > >
 > >Thanks a lot!
 > >
 > >Is there any easy way of automating this?
 > >So that whenever a line is broken and I type a '+' it vertically aligns
 > >the operator with the first one on the previous line.
 > >
 > >It would also be great if this could be done when I use = (re)format the
 > >entire file.
 > >
 > >
 >
 > I should also point out Vim's indenting system.  See :he indent-expression.
 > If you merely want initial operator alignment, you perhaps could use
 > Vim's indentexpr option.  One could probably call Align from a indenting
 > function, too.  There are a number of examples of indenting functions; see
 > $VIMRUNTIME/indent for 43 such files (to see what $VIMRUNTIME is,
 > fire up vim, then :echo $VIMRUNTIME).
 >
 > Regards,
 > Chip Campbell
 >
 >

Indeed. I had a quick go at this. I modified 'indentkeys'
and had 'indentexpr' set to a function that checked the
first non-blank of the line. If it was an initial operator
then it retrieved the appropriate indent from the previous
line. Otherwise it used cindent() to get the indent. It
seemed to work well but I hadn't tested it extensively.

Unfortunately I clumsily lost the file right before posting.
But it was a straightforward task so you shouldn't have
problems recreating these steps.

Antony
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic