Saturday, October 29, 2011

Re: Formatting C++ files

On 10/29/2011 1:06 AM, Taylor Hedberg wrote:
> I assume that not every function in the headers is called "AFunction"
> with void return type, so this is a little more liberal than precisely
> what you stated. It will apply to any line that has some whitespace,
> followed by one or more words (the return type, including '*' for
> pointer types), followed by a function name and its argument list.
>
> :%s/\v^\s+([a-zA-Z_* ]+)\s+(\*?)(\s*\w+\(.*\);)$/\t\t\1\2\t\t\t\t\t\t\t\t\3/
>
That is great! It "kind" of works.
One question. Would it be possible instead of all the tabs, position the "last"
part on say position 49 on the line? This because, sometimes the first token(s)
is really long, causing something like the following:

mtkVirtualHole* GetVirtualBond(const int& i);
void DeleteVirtualBond();

where desired result is
mtkVirtualHole* GetVirtualBond(const int& i);
void DeleteVirtualBond();
(used fewer tabs here for simplicity)


-totte


--
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

No comments:

Post a Comment