2013-06-18 31 views
5

我已經按照我的vimrc映射:Vim - 如何使你自己的映射可重複?

nmap <Leader>h1 yyp<c-v>$r= 
nmap <Leader>h2 yyp<c-v>$r- 

我想重複<Leader>h1/2.

,不存在與repeat.vim插件由蒂姆教皇有以下用法線

silent! call repeat#set("\<Plug>MyWonderFulMap", v:count) 

我嘗試以下方式使用它:

nnoremap <silent> <Plug>MyWonderfulMap :normal yyp<c-v>$r= 
silent! call repeat#set("\<Plug>MyWonderfulMap", v:count) 
nmap <Leader>h1 <Plug>MyWonderfulMap 

它不起作用。

我知道這不是一個嚴重的併發症,但是,我有興趣爲自己的映射使用repeat.vim。

+0

也http://vimcasts.org/看episodes/creating-repeatable-mappings-with-repeat-vim/ – Hotschke

回答

6

repeat#set()調用必須映射調用後映射定義後進行的,不只是一次。隨着:normal,你必須與:execute來包裝這是能夠追加:call,但實際上你的映射並不需要使用:normal都:

:nnoremap <silent> <Plug>MyWonderfulMap yyp<c-v>$r=:silent! call repeat#set("\<Plug>MyWonderfulMap", v:count)<CR> 
:nmap <Leader>h1 <Plug>MyWonderfulMap 
+1

謝謝。這工作。 – Hotschke