首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >VIM:可映射(未使用)的快捷方式字母?

VIM:可映射(未使用)的快捷方式字母?
EN

Stack Overflow用户
提问于 2009-12-12 01:29:06
回答 3查看 9.9K关注 0票数 22

我正在尝试创建两个对我自己有效的映射:

代码语言:javascript
复制
map X ddp

我会用它来一次性删除和粘贴。

代码语言:javascript
复制
map X "_dw

这将删除一个单词,而不会拖入寄存器。

然而,我不想破坏任何现有的,有用的快捷键,所以我想知道我可以使用什么键-有什么建议吗?我是不是太整洁了?

EN

回答 3

Stack Overflow用户

发布于 2009-12-12 07:48:31

vim help有一个部分:映射哪个键

代码语言:javascript
复制
1.7 WHAT KEYS TO MAP                                    *map-which-keys*

If you are going to map something, you will need to choose which key(s) to use
for the {lhs}.  You will have to avoid keys that are used for Vim commands,
otherwise you would not be able to use those commands anymore.  Here are a few
suggestions:
- Function keys <F2>, <F3>, etc..  Also the shifted function keys <S-F1>,
  <S-F2>, etc.  Note that <F1> is already used for the help command.
- Meta-keys (with the ALT key pressed). |:map-alt-keys|
- Use the '_' or ',' character and then any other character.  The "_" and ","
  commands do exist in Vim (see |_| and |,|), but you probably never use them.
- Use a key that is a synonym for another command.  For example: CTRL-P and
  CTRL-N.  Use an extra character to allow more mappings.

See the file "index" for keys that are not used and thus can be mapped without
losing any builtin function.  You can also use ":help {key}^D" to find out if
a key is used for some command.  ({key} is the specific key you want to find
out about, ^D is CTRL-D).
票数 22
EN

Stack Overflow用户

发布于 2009-12-13 00:36:53

通常,我使用control +字母或alt +字母进行大多数映射,这是安全的,但要注意'w‘,因为窗口命令需要使用它。您可能还会对arpeggio.vim感兴趣,它允许您创建到同时按下的键组的映射-它将极大地扩展您的映射的可能性,而不会有过度映射的危险。例如,您可以映射"dp“(同时按下)来执行"ddp”,以便在一个命令中删除和粘贴。

票数 5
EN

Stack Overflow用户

发布于 2009-12-12 08:10:14

嗯,不,不要。在创建映射时,尽量不要覆盖任何内容...这并不是因为你没有使用你要覆盖的命令,而是因为你已经拥有/或者将要拥有的一些插件可能会使用它。

然后你覆盖它,然后你就不得不担心了。

就我个人而言,对于您举的例子这样的命令,我喜欢Ctrl+some组合键。在vim中有很多免费的,那么Ctrl附近左边的字母就是很好的一对。

顺便说一句,你想用这些映射做什么…我理解第二个(逐字删除),但第一个对我没有意义。它应该做什么呢?转置线条?

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1889596

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档