Hi jaywee, The simplest way is using a mapping inoremap { {<cr>}<esc>O which should do what you want.
But I myself find this terrible annying because it always inserts those closing braces. That's why I've written some kind of context sensitive completion http://www.mawercer.de/marcweber/vim/installer/vimlib_contextcompletion_installer_sourceme.vim After sourceing you can save to different folder and use set runtime+=differentfolder. Then you can use call vl#lib#completion#contextcompletion#InitContextCompletion( \ [ [ "Tab",'<tab>','b:tab_compl'] \ , [ "MCR" ,"<m-cr>" ,'b:mcr_compl', "\<cr>" ] \ , [ "CR" ,"<cr>" ,'b:cr_compl', "\<cr>" ] \ , [ "BO" ,"{" ,'b:bo_compl', "{" ] \ ] \ ) " this will generate severeal commands " You are interested in " (BO = brace open ;) AddBOCompletion bcm: {\<cr>}\<esc>O If you only want this behaviour after functions and whiles I'd suggest AddBOCompletion bcm:)$ {\<cr>}\<esc>O which means do this only if the regex )$ matches before the cursor Here are some further examples which map d id < " to #ifdef #include <|> #include "|" function! vl#dev#cpp#context_completions#AddCPPCompletions() AddTabCompletion ^d \<bs>#define ts: AddTabCompletion ^id \<bs>\<bs>#ifdef\<cr>#endif\<esc>-A ts: AddTabCompletion ^< \<bs>#include\<space><>\<left> AddTabCompletion ^\" \<bs>#include\<space>\"\"\<left> endfunction If more than one context matches you'll get a list or can resolve it by adding AddTabCompletion a a\<space>tab\<space>pressed AddTabCompletion a a\<space>tab\<space>pressed2 fitness:2 which means use the second because its fitness is greater. I've mapped opening cloning brace to <m-cr> (AddMCRCompletion) to be able to decide wether I want this behaviour.. My scipts are overkill for this task but they might become handy if you really many mappings because you can map more than one string/action to the same key. Marc