Question: How do I implement a curly brace quote auto-complete in vim, including HTML tags? Workaround: As long as the following two pieces of code pasted into ~/.VIMRC, you can implement the parentheses to complete the full <!--bracket quotation mark complete code {{{--> "bracket quotation mark complement Inoremap (() <esc>iinoremap [[]<esc >iinoremap {{<cr>}<esc>oinoremap) <c-r>=closepair (') ') <cr>inoremap] <c-r>= Closepair ('] ') <cr>inoremap} <c-r>=closebracket () <cr>inoremap "<c-r>=quotedelim ('") < Cr>inoremap ' <c-r>=quotedelim ("')") <cr>function Closepair (char) if getline ('. ') [Col ('. ')-1] = = A:charreturn "\<right>" Elsereturn a:charendifendffunction closebracket () if Match (Getline (line ( '.') + 1), ' \s*} ') < 0return "\<CR>}" Elsereturn "\<esc>j0f}a" Endifendffunction Quotedelim (char) Let line = Getline ('. ') Let col = col ('. ') If line[col-2] = = "\" "Inserting a quoted quotation mark into the Stringreturn a:charelseif line[col-1] = = A:char" Esca Ping out of the Stringreturn "\<right>" Else "starting a stringreturn A:char.a:char." \<esc>i "endifendf<!--}}}--><!--HTML Tag Auto-complete {{{--> "HTML auto-complete autocmd bufnewfile * setlocal filetype=htmlfunction! Inserthtmltag () Let Pat = ' \c<\w\+\s*\ (\s\+\w\+\s*=\s*[' #$;, (). " a-z0-9]\+\) *\s*> ' normal! A>let save_cursor = GetPos ('. ') Let result = Matchstr (Getline (save_cursor[1]), Pat) "if (Search (Pat, ' B ', save_cursor[1]) && searchpair (' < ', ' ', ' > ', ' bn ', 0, Getline ('. ') > 0) if (Search (Pat, ' B ', save_cursor[1]) normal! lyiwf>normal! a</normal! pnormal! A>endif:call cursor (save_cursor[1], save_cursor[2], save_cursor[3]) endfunctioninoremap > <esc>:call Inserthtmltag () <CR>a<CR><Esc>O<!--}}}--> The function in the completion code of the parentheses here is matched when entering (input content) and then pressing) The system automatically checks to see if there are any matching parentheses, if any, but instead of typing it out, you might want to add: Set Autoindentset cindent reference: http://www.cnblogs.com/huanlei/archive/2012 /04/02/2430153.htmlhttp://blog.sina.com.cn/s/blog_01ea59580101hvth.html
0008 Vim Bracket Quote HTML tag Auto complement