On Sun, Apr 01, 2007 at 06:01:34AM +0200, A.J.Mechelynck wrote: > A.J.Mechelynck wrote: > >Greg Fitzgerald wrote: > >>Anyone know of a way to achieve bracket completion? For example if > >>your typing a if statement, if (something) { once you type the first > >>bracket > >>the 2nd one is inserted below for you. Scribes and a few other editors > >>have this functionality and was hoping to achieve it with Vim. Another > >>thing that this does, if you were to type $data[' for example. The 2nd ' > >>would be inserted for you after your cursor. Just seems to save time > >>when I played with scribes a few days ago. I was looking through the > >>help, scripts and mailing list archives for something like this but have > >>not hit any matches. Just wondering if people have ideas on how this > >>could be done or maybe know of an existing way. Thanks in advance. > >> > >>--Greg > >> > > > > :inoremap { {<CR>}<Up><End> > > :inoremap [ []<Left> > > :inoremap ( ()<Left> > > > >etc. > > > >This assumes brace indenting is taken care of (by 'cindent' or > >'indentexpr'). > > > >IIUC, you can still enter an "unpaired brace" (or bracket or paren) by > >prefixing it with Ctrl-V (or with Ctrl-Q if Ctrl-V pastes). > > > >Best regards, > >Tony. > > P.S. If you implement it for quotes, you may want to disable it for > vimscript, which has unpaired double quotes (marking off comments) and > unpaired single and double quotes (in the argument of ":normal" for > registers or marks). > > Best regards, > Tony. > -- > hundred-and-one symptoms of being an internet addict: > 156. You forget your friend's name but not her e-mail address.
Great advice Tony. Thanks for the really quick response as well. I'll just add a statment enabling this for certain languages. This has also giving me a couple new ideas to play with. Thanks again. :) --Greg