Skip to content

Commit

Permalink
resolve issue #23: add more shortcuts for closing tags
Browse files Browse the repository at this point in the history
  • Loading branch information
alvan committed Jul 31, 2017
1 parent 2cacc50 commit 527bb10
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
23 changes: 14 additions & 9 deletions README.md
Expand Up @@ -37,22 +37,27 @@ The following tags will not be closed:
Set in your vimrc:

" filenames like *.xml, *.html, *.xhtml, ...
" Then after you press <kbd>&gt;</kbd> in these files, this plugin will try to close the current tag.
"
let g:closetag_filenames = '*.html,*.xhtml,*.phtml'

Then after you press <kbd>&gt;</kbd> in these files, this plugin will try to close the current tag.

You can set:

" filenames like *.xml, *.xhtml, ...
" This will make the list of non closing tags self closing in the specified files.
"
let g:closetag_xhtml_filenames = '*.xhtml,*.jsx'

This will make the list of non closing tags self closing in the specified files.

You can set:

" integer value [0|1]
" This will make the list of non closing tags case sensitive (e.g. `<Link>` will be closed while `<link>` won't.)
"
let g:closetag_emptyTags_caseSensitive = 1

This will make the list of non closing tags case sensitive (e.g. `<Link>` will be closed while `<link>` won't.)
" Shortcut for closing tags, default is '>'
"
let g:closetag_shortcut = '>'

" Add > at current position without closing the current tag, default is '<leader>>'
"
let g:closetag_close_shortcut = '<leader>>'

#### Commands

Expand Down
15 changes: 12 additions & 3 deletions plugin/closetag.vim
Expand Up @@ -9,7 +9,7 @@
if exists("g:loaded_closetag")
finish
endif
let g:loaded_closetag = "1.7.4"
let g:loaded_closetag = "1.7.5"

if !exists('g:closetag_filenames')
let g:closetag_filenames = "*.html,*.xhtml,*.phtml"
Expand All @@ -29,8 +29,17 @@ if !exists('g:closetag_emptyTags_caseSensitive')
let g:closetag_emptyTags_caseSensitive = 0
endif

exec "au BufNewFile,Bufread " . g:closetag_filenames . " inoremap <silent> <buffer> > ><Esc>:call <SID>CloseTagFun()<Cr>"
au User vim-closetag inoremap <silent> <buffer> > ><Esc>:call <SID>CloseTagFun()<Cr>
if !exists('g:closetag_shortcut')
let g:closetag_shortcut = ">"
endif

if !exists('g:closetag_close_shortcut')
let g:closetag_close_shortcut = "<leader>>"
endif

exec "au BufNewFile,Bufread " . g:closetag_filenames . " inoremap <silent> <buffer> " . g:closetag_close_shortcut . " >"
exec "au BufNewFile,Bufread " . g:closetag_filenames . " inoremap <silent> <buffer> " . g:closetag_shortcut . " ><Esc>:call <SID>CloseTagFun()<Cr>"
exec "au User vim-closetag inoremap <silent> <buffer> " . g:closetag_shortcut . " ><Esc>:call <SID>CloseTagFun()<Cr>"

if g:closetag_xhtml_filenames != ''
exec "au BufNewFile,Bufread " . g:closetag_xhtml_filenames . " call <SID>Declare('b:closetag_use_xhtml', 1)"
Expand Down

0 comments on commit 527bb10

Please sign in to comment.