From: Iain Patterson Date: Wed, 26 Feb 2014 10:54:35 +0000 (+0000) Subject: More specific Mapping(). X-Git-Url: http://git.iain.cx/?a=commitdiff_plain;h=1284f479e72e999367bcf8cc983b07e23229438b;p=profile.git More specific Mapping(). Add an extra argument to Mapping() to define the specific modes which it should affect. --- diff --git a/.vimrc b/.vimrc index 8c8f8f9..f572ab2 100644 --- a/.vimrc +++ b/.vimrc @@ -425,11 +425,23 @@ fun! MakeMode_unmap() "{{{2 endfun "}}}2 " Function to create mappings with either a hardcoded \ or . -fun! Mapping(keysequence,mapping) "{{{2 +fun! Mapping(keysequence, mapping, ...) "{{{2 if version < "600" - exec "map \\" . a:keysequence . " " . a:mapping . ":" + let l:args = "\\" . a:keysequence . " " . a:mapping . ":" else - exec "map " . a:keysequence . " " . a:mapping + let l:args = " " . 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 @@ -1265,9 +1277,9 @@ if version >= "700" "{{{1 version 7.0 " Narrow buffer with \w. -call Mapping("w", ":NarrowRegion") +call Mapping("w", ":NarrowRegion", "n", "v") " Narrow window with \W. -call Mapping("W", ":NarrowWindow") +call Mapping("W", ":NarrowWindow", "n", "v") " Helper to show tab name. fun! TabName(label, gui) "{{{2