" use [w and ]w and [W and ]W to exchange a word/WORD under the cursor with
" the prev/next one
nnoremap ]w mx$ox<ESC>kJ`xdawhelphmx$"_daw`xh
nnoremap ]W mx$ox<ESC>kJ`xdaWElphmx$"_daw`xh
nnoremap [w mx$ox<ESC>kJ`xdawbPhmx$"_daw`xh
nnoremap [W mx$ox<ESC>kJ`xdaWBPhmx$"_daw`xh
" apply the repeat plugin to any mapping
function! Repeat(mapname, map, command)
execute 'nnoremap <silent> <Plug>'.a:mapname.' '.a:command.
\' :call repeat#set("\<Plug>'.a:mapname.'")<CR>'
execute 'nmap '.a:map.' <Plug>'.a:mapname
endfunction
" use [w and ]w and [W and ]W to exchange a word/WORD under the cursor with
" the prev/next one
call Repeat('WordForward', ']w', 'mx$ox<ESC>kJ`xdawhelphmx$"_daw`xh')
call Repeat('WORDForward', ']W', 'mx$ox<ESC>kJ`xdaWElphmx$"_daw`xh')
call Repeat('WordBackward', '[w', 'mx$ox<ESC>kJ`xdawbPhmx$"_daw`xh')
call Repeat('WORDBackward', '[W', 'mx$ox<ESC>kJ`xdaWBPhmx$"_daw`xh')
1条答案
按热度按时间sqougxex1#
我一直想创建一些干净的函数来实现这一点(也许其他人会提供它们),但现在我在vimrc中有以下(hacky)重Map:
使用tpope的vim-repeat使它们可重复