Re: [PATCH 4/8] rev-parse: teach "git rev-parse --symbolic" to print the full ref name
- From
Brian Gernhardt <benji@silverinsanity.com>
- Date
- Oct 28, 2007, 15:10 UTC
- Message-ID
- <3849CD8A-A86C-4297-899F-F1B7C1E81F2C@silverinsanity.com>
- In-Reply-To
- <30641295-495B-4E5E-9D44-5CAF7C480DF2@zib.de>
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