[英]VIM special chars without shift key
I write a lot of code and tired of pressing shift each time I need a special character. 我编写了大量代码,并且每次需要特殊字符时都厌倦了按shift键。 And since I use special chars much often, then numbers, I want to reverse shift behavior on them. 而且由于我经常使用特殊字符,然后使用数字,所以我想反转它们的移位行为。
So, if I type <4> I'll get '$' and if I type <shift>+<4> I'll get '4' and so on for each number. 因此,如果我键入<4>,我将得到'$',而如果键入<shift> + <4>,我将得到'4',依此类推。 This mapping should work only in insert mode. 此映射应仅在插入模式下工作。
I've tried: 我试过了:
:set langmap 123...;!@#...,!@#...;123 "works only in normal-mode
:imap 4 $
:imap $ 4 "recursive mapping error
Use :ino
, which does the same thing as :imap
except that it doesn't look for maps in the replaced text. 使用:ino
,它与:imap
相同,不同之处在于它不会在替换的文本中查找地图。 (it's short for 'inoremap') That will fix the recursion issue. (“ inoremap”的缩写)将解决递归问题。
See here for more information: http://vim.dindinx.net/orig/html/map.txt.php 有关更多信息,请参见此处: http : //vim.dindinx.net/orig/html/map.txt.php
Or type :h map for vim online help (same thing, just inside vim). 或输入:h map以获得vim联机帮助(相同的内容,仅在vim内部)。
From :help imap
: 来自: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".
Same applies to imap
(use inoremap
instead). 同样适用于imap
(改为使用inoremap
)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.