On Oct 28, 2007, at 4:56 AM, Steffen Prohaska wrote:
I can't teach vim to always place the '*' correctly. At least I
don't know how to do this.
I did some research (I was curious), and the following in your .vimrc
will do it: (Mildly tested)
-----8<-----
" Needed to avoid 'char * '
func s:Eatchar(pat)
let c = nr2char(getchar(0))
return (c =~ a:pat) ? '' : c
endfunc
" Make creating the abbreviation for multiple types easier
func s:FixPointer(type)
exec "iabbr " . a:type . "* " . a:type . " *<C-R>=<SID>Eatchar('\
\s')<CR>"
endfunc
command -nargs=1 FixPointer call <SID>FixPointer(<args>)
" Change the following pointer types (char* var -> char *var)
FixPointer 'char'
FixPointer 'int'
FixPointer 'void'
-----8<-----
Repeating the last line for each type you want to fix the pointers
for. There may be a simpler way to do some of this, but I don't know
it. But once it's set up each time you type in "char* var", Vim will
auto-correct to "char *var".
Changing this to operate only in C, or only if you're starting in your
git repository is left as an exercise for the reader. ;-)
~~ Brian
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html