VIM特殊字符不带shift键
问题描述:
我写了很多代码,每次需要特殊字符时都会按shift键。而且由于我经常使用特殊的字符,那么数字,我想扭转他们的移动行为。VIM特殊字符不带shift键
所以,如果我键入< 4>我会得到“$”,如果我键入<转变> + < 4>我会得到“4”等每个号码。该映射只能在插入模式下使用。
我已经试过:
:set langmap 123...;[email protected]#...,[email protected]#...;123 "works only in normal-mode
:imap 4 $
:imap $ 4 "recursive mapping error
答
使用:ino
,它做同样的事情作为:imap
,只是它看起来并不在替换文本地图。 (这是'inoremap'的简称)这将解决递归问题。
在这里看到更多的信息: http://vim.dindinx.net/orig/html/map.txt.php
或者类型:H地图vim的在线帮助(同样的事情,只是里面VIM)。
答
从:help imap
:
If you want to exchange the meaning of two keys you should use the :noremap
command. For example: >
:noremap k j
:noremap j k
This will exchange the cursor up and down commands.
With the normal :map command, when the 'remap' option is on, mapping takes
place until the text is found not to be a part of a {lhs}. For example, if
you use: >
:map x y
:map y x
Vim will replace x with y, and then y with x, etc. When this has happened
'maxmapdepth' times (default 1000), Vim will give the error message
"recursive mapping".
同样适用于imap
(使用inoremap
代替)。