VIM输入模式键盘映射教程

本文是一篇关于如何在Vim编辑器中从插入模式映射正常模式命令的教程。介绍了使用<CTRL-O>和<CTRL-/><CTRL-O>在不改变光标位置的情况下执行命令,并讨论了如何使用<C-R>=命令插入表达式的结果,以及在映射中处理字符串解析的问题。
摘要由CSDN通过智能技术生成

http://vim.wikia.com/wiki/Mapping_keys_in_Vim_-_Tutorial_(Part_1)

To execute Vim normal mode commands from an insert mode map, you have to go from insert mode to normal mode. But after executing the map, you may want to restore the mode back to insert mode. To do this, you can use the <CTRL-O> insert-mode key which temporarily goes to normal-mode for one normal mode command and then comes back to insert mode. For example, to call the Vim function MyVimFunc() from insert mode, you can use the following map command:

:inoremap <F5> <C-O>:call MyVimFunc()<CR>

One caveat with using the <C-O> command is that if the cursor is after the last character in a line in insert mode, then <C-O> moves the cursor one character to the left after executing the map. If you don't want this, then you can use the <C-/><C

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值