endfun "}}}2
" Function to create mappings with either a hardcoded \ or <Leader>.
-fun! Mapping(keysequence,mapping) "{{{2
+fun! Mapping(keysequence, mapping, ...) "{{{2
if version < "600"
- exec "map \\" . a:keysequence . " " . a:mapping . ":<CR>"
+ let l:args = "\\" . a:keysequence . " " . a:mapping . ":<CR>"
else
- exec "map <silent> <Leader>" . a:keysequence . " " . a:mapping
+ let l:args = "<silent> <Leader>" . a:keysequence . " " . a:mapping
+ endif
+ if a:0 == 0
+ " General mapping.
+ exec "map " . l:args
+ else
+ " Specific mapping(s).
+ let l:i = 1
+ while l:i <= a:0
+ exec "let l:map = a:" . l:i . " . \"map\""
+ exec l:map . " " . l:args
+ let l:i = l:i + 1
+ endwhile
endif
endfun "}}}2
version 7.0
" Narrow buffer with \w.
-call Mapping("w", ":NarrowRegion<CR>")
+call Mapping("w", ":NarrowRegion<CR>", "n", "v")
" Narrow window with \W.
-call Mapping("W", ":NarrowWindow<CR>")
+call Mapping("W", ":NarrowWindow<CR>", "n", "v")
" Helper to show tab name.
fun! <SID>TabName(label, gui) "{{{2