Permalink
Browse files

Improve mapping for Vim, using <Plug> maps>

Add redirection through <Plug>SparkupExecute and <Plug>SparkupNext and
check if mappings are defined for them before assigning default maps.
  • Loading branch information...
1 parent 7ab92a4 commit 72deab12279a9222ae586ade9acffcb442c71551 @blueyed committed Apr 5, 2011
Showing with 9 additions and 2 deletions.
  1. +9 −2 vim/ftplugin/html/sparkup.vim
@@ -26,8 +26,15 @@ if !exists('g:sparkupNextMapping')
let g:sparkupNextMapping = '<c-n>'
endif
-exec 'imap <buffer> ' . g:sparkupExecuteMapping . ' <c-g>u<Esc>:call <SID>Sparkup()<cr>'
-exec 'imap <buffer> ' . g:sparkupNextMapping . ' <c-g>u<Esc>:call <SID>SparkupNext()<cr>'
+imap <buffer> <Plug>SparkupExecute <c-g>u<Esc>:call <SID>Sparkup()<cr>
+imap <buffer> <Plug>SparkupNext <c-g>u<Esc>:call <SID>SparkupNext()<cr>
+
+if ! hasmapto('<Plug>SparkupExecute', 'i')
+ exec 'imap <buffer> ' . g:sparkupExecuteMapping . ' <Plug>SparkupExecute'
+endif
+if ! hasmapto('<Plug>SparkupNext', 'i')
+ exec 'imap <buffer> ' . g:sparkupNextMapping . ' <Plug>SparkupNext'
+endif
if exists('*s:Sparkup')
finish

0 comments on commit 72deab1

Please sign in to comment.