From f95d13e251bf24782319f21a673ce5a1de79dcc1 Mon Sep 17 00:00:00 2001 From: David Ben Knoble Date: Sat, 2 Mar 2019 23:41:08 -0500 Subject: [PATCH] Map uniquely If a previous mapping using the provided key sequence is defined, the map will fail. silent! prevents this from being a problem (stopping execution or displaying annoying errors). The long-term effect is to avoid overwriting user mappings in the qf window. A second solution would be, for each `{map} {lhs} {rhs}` command, to use try {map} {lhs} {rhs} catch /E227/ endtry which accomplishes the same effect less concisely. --- autoload/ack.vim | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/autoload/ack.vim b/autoload/ack.vim index b6afdba4..f4c31892 100644 --- a/autoload/ack.vim +++ b/autoload/ack.vim @@ -114,26 +114,26 @@ function! s:ApplyMappings() "{{{ let l:closemap = ':' . l:wintype . 'close' let g:ack_mappings.q = l:closemap - nnoremap ? :call QuickHelp() + silent! nnoremap ? :call QuickHelp() if g:ack_autoclose " We just map the 'go' and 'gv' mappings to close on autoclose, wtf? for key_map in items(g:ack_mappings) - execute printf("nnoremap %s %s", get(key_map, 0), get(key_map, 1) . l:closemap) + silent! execute printf("nnoremap %s %s", get(key_map, 0), get(key_map, 1) . l:closemap) endfor - execute "nnoremap " . l:closemap + silent! execute "nnoremap " . l:closemap else for key_map in items(g:ack_mappings) - execute printf("nnoremap %s %s", get(key_map, 0), get(key_map, 1)) + silent! execute printf("nnoremap %s %s", get(key_map, 0), get(key_map, 1)) endfor endif if exists("g:ackpreview") " if auto preview in on, remap j and k keys - nnoremap j j - nnoremap k k - nmap j - nmap k + silent! nnoremap j j + silent! nnoremap k k + silent! nmap j + silent! nmap k endif endfunction "}}}