无法成功使用来自vimrc(mac)的自定义映射vim命令
我正在尝试将命令添加到我的无法成功使用来自vimrc(mac)的自定义映射vim命令,vim,Vim,我正在尝试将命令添加到我的.vimrc并使用它 我记录了一个宏(在寄存器h中),该宏打印以下内容(以换行符结尾): 我可以通过键入:reg在寄存器h中看到这一点。它看起来像: "h ione^Mtwo^Mthree^M^[ 我已经在我的.vimrc中分别在test和test2下粘贴了此版本和备用版本: map <Leader>test ione^Mtwo^Mthree^M^[ map <Leader>test2 ione<C-R>two<C-R&g
.vimrc
并使用它
我记录了一个宏(在寄存器h
中),该宏打印以下内容(以换行符结尾):
我可以通过键入:reg
在寄存器h
中看到这一点。它看起来像:
"h ione^Mtwo^Mthree^M^[
我已经在我的.vimrc
中分别在test
和test2
下粘贴了此版本和备用版本:
map <Leader>test ione^Mtwo^Mthree^M^[
map <Leader>test2 ione<C-R>two<C-R>three<C-R><ESC>
最后,在正常模式下,我再试一次,这次是反斜杠。我尝试以下两种方法:
:\test
:\test2
这一次,我收到两个命令的以下错误:
E10: \ should be followed by /, ? or &
我在一台mac电脑上,试过使用终端(OSX附带)和iTerm2
有人能给我一些指导吗?如果您按引导键,然后按键
test
或test2
,将执行映射。您没有创建命令(:
)
如果希望将它们作为命令,则不需要映射,而是在.vimrc
:
function! Test()
execute "normal ione"
execute "normal otwo"
execute "normal othree"
execute "normal o"
endfunc
command -nargs=0 Test call Test()
然后可以将其用作:Test
但是,如果要进行映射而不是命令,则可能需要:
- 到类型的较短映射(这是非常主观的)
- 要使用
而不是nnoremap
(仅在正常模式下可用,并且不递归执行映射)map
- 您的
就是您所需要的(我在这里将其更改为test2
)t
是
,您希望返回键为控制R
nnoremap <Leader>t ione<CR>two<CR>three<CR><ESC>
nnoremap t ionetwo-three
function! Test()
execute "normal ione"
execute "normal otwo"
execute "normal othree"
execute "normal o"
endfunc
command -nargs=0 Test call Test()
nnoremap <Leader>t ione<CR>two<CR>three<CR><ESC>