tpope / vim-repeat

repeat.vim: enable repeating supported plugin maps with "."
http://www.vim.org/scripts/script.php?script_id=2136
2.58k stars 81 forks source link

Problem with vim-repeat and remapping keys #58

Open oskarkv opened 7 years ago

oskarkv commented 7 years ago

I don't have the qwerty layout, and so want to remap some keys, in particular u.

Looking at vim-repeat, it seems I should be able to just map another key to RepeatUndo, like so:

nmap k <Plug>(RepeatUndo)

and vim-repeat will not overwrite my u mapping, because it checks for a mapping with hasmapto.

The problem is that unless I have used a command that requires vim-repeat, for example, used vim-surround, my k key does not undo anything. It starts working only after I have used vim-surround.

tpope commented 7 years ago

So a hackish but probably adequate solution would to add the following to your vimrc:

if empty(mapcheck("<Plug>(RepeatUndo)"))
  nnoremap <Plug>(RepeatUndo) u
endif