我写了很多代码,每次需要特殊字符时都厌倦了按 shift 键。而且由于我经常使用特殊字符,然后是数字,我想反转它们的移位行为。
因此,如果我输入 <4>,我会得到 '$',如果我输入 <shift>+<4>,我会得到 '4',以此类推。此映射应仅在插入模式下工作。
我试过了:
:set langmap 123...;!@#...,!@#...;123 "works only in normal-mode
:imap 4 $
:imap $ 4 "recursive mapping error
我写了很多代码,每次需要特殊字符时都厌倦了按 shift 键。而且由于我经常使用特殊字符,然后是数字,我想反转它们的移位行为。
因此,如果我输入 <4>,我会得到 '$',如果我输入 <shift>+<4>,我会得到 '4',以此类推。此映射应仅在插入模式下工作。
我试过了:
:set langmap 123...;!@#...,!@#...;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 map 获取 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改为使用)。