Skip to content

Commit 3b40261

Browse files
committed
Use maparg to check for previous mappings
As per issue #12, fail to map using map-<unique> and emit a message directing users to #18
1 parent c6b96be commit 3b40261

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

autoload/yankstack.vim

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,12 @@ function! yankstack#setup()
161161
let word_characters = split("qwertyuiopasdfghjklzxcvbnm1234567890_", '\zs')
162162

163163
for key in g:yankstack_yank_keys
164-
exec 'nnoremap <expr>' key '<SID>yank_with_key("' . key . '")'
165-
exec 'xnoremap <expr>' key '<SID>yank_with_key("' . key . '")'
164+
if maparg(key, "x") != ""
165+
echom "The key " . key . " is already mapped as " . maparg(key, "x")
166+
echom "See https://github.com/maxbrunsfeld/vim-yankstack/issues/18 for details"
167+
endif
168+
exec 'nnoremap <unique> <expr>' key '<SID>yank_with_key("' . key . '")'
169+
exec 'xnoremap <unique> <expr>' key '<SID>yank_with_key("' . key . '")'
166170
endfor
167171

168172
let clear_cmd = ':echo ""<CR>'

0 commit comments

Comments
 (0)