VIM:可映射(未使用)的快捷字母?
我正在尝试创建两个对我自己来说有效的映射:
map X ddp
我将用它来一次性删除和粘贴。
map X "_dw
这将删除一个单词而不用拉入寄存器。
然而,我不想破坏任何现有的、有用的快捷键,所以我想知道我可以使用哪些键 - 有什么建议吗?我是不是太讲究了?
I'm trying to create two mappings which are efficient for myself:
map X ddp
Which I'd use to delete and paste in one go.
map X "_dw
Which would delete a word without yanking into a register.
However I don't want to break any existing, useful shortcuts so I'm wondering what keys I could use - any suggestions? Am I being too uptidy?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
vim 帮助中有一个部分 :he map-which-keys
vim help has a section :he map-which-keys
许多 Vim 插件使用初始
来启动其按键序列;这是一个(否则通常)未使用的密钥,可由用户配置。Many Vim plugins use an initial
<Leader>
to start their key sequences; this is an (otherwise normally) unused key that is configurable by the user.每个 ASCII 字符,无论大小写,在 Vim 中都用于表示某些内容。所以你最终会覆盖一些东西——只需选择一些你不使用的东西。对您自己的扩展使用常见的习惯用法可能会有所帮助。例如,我使用前导逗号:(
最后一个对我特别有用,因为我几乎不需要在插入模式下写入两个连续的逗号,而且不必一直按 Esc 键,这很好。)
Every single ASCII character, upper and lower case, is used for something in Vim. So you're going to wind up overwriting something--just pick something that you don't use. It may help to use a common idiom for your own extensions. I use a leading comma, for example:
(The last is particularly useful for me, since I pretty much never need to write two consecutive commas in insert mode, and it's nice not to have to go all the way to the Esc key.)
通常,我对大多数映射使用 control + [字母] 或 alt + [字母],这是安全的,但要注意“w”,因为窗口命令需要它。您可能还对 arpeggio.vim 感兴趣,它可以让您创建到同时按下按键组 - 它将极大地扩展您的映射的可能性,而不会出现过度映射某些内容的危险。例如,您可以映射“dp”(同时按下)来执行“ddp”以在一个命令中删除和粘贴。
Typically I use control + [letter] or alt + [letter] for most mappings and it's safe, but watch out for 'w' since that's needed for window commands. You might also be interested in arpeggio.vim which lets you create mappings to simultaneously pressed groups of keys - it will massively expand the possibilities for your mappings with no danger of over-mapping something. For example, you could map "dp" (pressed simultaneously) to execute "ddp" to delete and paste in one command.
嗯,不,不要。创建映射时,尽量不要覆盖任何内容……不是因为您没有使用您要过度映射的命令,而是因为您拥有/或将拥有的某些插件可能会使用它。
然后你过度映射它,然后你就不得不担心了。
就我个人而言,对于诸如您给出的示例之类的命令,我喜欢 Ctrl+一些组合键。 vim 中有很多免费的字母,那么左侧靠近 Ctrl 的字母就成了很好的一对。
顺便说一句,你想用这些映射做什么......我理解第二个(逐字删除),但第一个对我来说没有意义。它应该做什么?转置线 ?
Uhmm, no, don't. When creating your mappings try not to overwrite anything ... not so much because you don't use the command you're overmapping, but because some plugin which you have/or will have maybe using it.
And then you overmap it, and then you have to worry.
Personally, for commands such as you gave as an example, I like Ctrl+some key combinations. There are a lot of free ones in vim, and the letters on the left side near Ctrl make a nice pair then.
Btw, what are you trying to do with those mappings ... I understand the second one (delete word by word), but the first doesn't make sense to me. What is it supposed to do ? Transpose lines ?