# HG changeset patch # User Steve Losh # Date 1276738771 14400 # Node ID 985b6818cbfa8137470586fa49d823aca294190b # Parent eef01ecd123597f1d81044ea51b6fc793aa6ec92# Parent e6efd03a434ba5aaa59a2f49c56a4128cfa8ee5a Merge. diff -r eef01ecd1235 -r 985b6818cbfa vim/.vimrc --- a/vim/.vimrc Wed Jun 16 21:00:20 2010 -0400 +++ b/vim/.vimrc Wed Jun 16 21:39:31 2010 -0400 @@ -148,3 +148,7 @@ " Easier linewise reselection map v V`] + +" HTML tag closing +imap :call InsertCloseTag()a + diff -r eef01ecd1235 -r 985b6818cbfa vim/ftplugin/html/closetags.vim --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vim/ftplugin/html/closetags.vim Wed Jun 16 21:39:31 2010 -0400 @@ -0,0 +1,58 @@ +function! InsertCloseTag() +" inserts the appropriate closing HTML tag; used for the \hc operation defined +" above; +" requires ignorecase to be set, or to type HTML tags in exactly the same case +" that I do; +" doesn't treat

as something that needs closing; +" clobbers register z and mark z +" +" by Smylers http://www.stripey.com/vim/ +" 2000 May 3 + + if &filetype == 'html' + + " list of tags which shouldn't be closed: + let UnaryTags = ' Area Base Br DD DT HR Img Input Link Meta Param ' + + " remember current position: + normal mz + + " loop backwards looking for tags: + let Found = 0 + while Found == 0 + " find the previous <, then go forwards one character and grab the first + " character plus the entire word: + execute "normal ?\\l" + normal "zyl + let Tag = expand('') + + " if this is a closing tag, skip back to its matching opening tag: + if @z == '/' + execute "normal ?\" . Tag . "\" + + " if this is a unary tag, then position the cursor for the next + " iteration: + elseif match(UnaryTags, ' ' . Tag . ' ') > 0 + normal h + + " otherwise this is the tag that needs closing: + else + let Found = 1 + + endif + endwhile " not yet found match + + " create the closing tag and insert it: + let @z = '' + normal `z"zp + + else " filetype is not HTML + echohl ErrorMsg + echo 'The InsertCloseTag() function is only intended to be used in HTML ' . + \ 'files.' + sleep + echohl None + + endif " check on filetype + +endfunction " InsertCloseTag() diff -r eef01ecd1235 -r 985b6818cbfa vim/ftplugin/htmldjango/closetags.vim --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vim/ftplugin/htmldjango/closetags.vim Wed Jun 16 21:39:31 2010 -0400 @@ -0,0 +1,1 @@ +/Users/sjl/lib/dotfiles/vim/ftplugin/html/closetags.vim \ No newline at end of file