VIM 没有 Shift 键的特殊字符

发布于 2024-09-18 05:43:55 字数 317 浏览 1 评论 0原文

我写了很多代码,并且厌倦了每次需要特殊字符时都按 Shift 键。由于我经常使用特殊字符,然后是数字,所以我想反转它们的移位行为。

所以,如果我输入 <4>我会得到“$”,如果我输入+<4>我将为每个数字得到“4”等。此映射应仅在插入模式下工作。

我尝试过:

:set langmap 123...;!@#...,!@#...;123 "works only in normal-mode

:imap 4 $
:imap $ 4 "recursive mapping error

I write a lot of code and tired of pressing shift each time I need a special character. 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. 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

趴在窗边数星星i 2024-09-25 05:43:55

使用 :ino,它与 :imap 执行相同的操作,只不过它不在替换文本中查找地图。 (它是“inoremap”的缩写)这将解决递归问题。

请参阅此处了解更多信息:
http://vim.dindinx.net/orig/html/map.txt。 php

或者输入 :h map 来获取 vim 在线帮助(同样的事情,就在 vim 中)。

Use :ino, which does the same thing as :imap except that it doesn't look for maps in the replaced text. (it's short for 'inoremap') That will fix the recursion issue.

See here for more information:
http://vim.dindinx.net/orig/html/map.txt.php

Or type :h map for vim online help (same thing, just inside vim).

和我恋爱吧 2024-09-25 05:43:55

来自 :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 代替)。

From :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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文