From 7300acc032403be81a9297f2cf6317260730e655 Mon Sep 17 00:00:00 2001 From: Tim Brooks Date: Wed, 28 Jan 2015 19:15:53 +0000 Subject: [PATCH] Use maparg to check for previous mappings As per issue #12, fail to map using map- and emit a message directing users to #18 --- autoload/yankstack.vim | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/autoload/yankstack.vim b/autoload/yankstack.vim index 8feb49e..2e36fc8 100644 --- a/autoload/yankstack.vim +++ b/autoload/yankstack.vim @@ -161,8 +161,12 @@ function! yankstack#setup() let word_characters = split("qwertyuiopasdfghjklzxcvbnm1234567890_", '\zs') for key in g:yankstack_yank_keys - exec 'nnoremap ' key 'yank_with_key("' . key . '")' - exec 'xnoremap ' key 'yank_with_key("' . key . '")' + if maparg(key, "x") != "" + echom "The key " . key . " is already mapped as " . maparg(key, "x") + echom "See https://github.com/maxbrunsfeld/vim-yankstack/issues/18 for details" + endif + exec 'nnoremap ' key 'yank_with_key("' . key . '")' + exec 'xnoremap ' key 'yank_with_key("' . key . '")' endfor for key in paste_keys