简体   繁体   English

如何 <Plug> 在Vim工作?

[英]How does <Plug> work in Vim?

I didn't understand what <Plug> does and how to use it. 我不明白<Plug>做了什么以及如何使用它。 I read the documentation but it is not clear to me. 我阅读了文档,但我不清楚。

<Plug> is just a special, synthetic key that is never actually sent by the keyboard; <Plug>只是一个特殊的合成键,从未实际由键盘发送; ie you cannot type it. 即你不能输入它。

With this, the :map functionality that comes from old vi can be used as an abstraction layer for plugins. 有了这个,来自旧vi的:map功能可以用作插件的抽象层。

Instead of directly mapping plugin functionality to a fixed key, plugins define a <Plug>PluginNameFunctionName mapping, which can then be freely remapped to the desired key by the user. 插件定义了<Plug>PluginNameFunctionName映射,而不是直接将插件功能映射到固定键,然后用户可以将其自由地重新映射到所需的键。 As Vim allows to check for existing mappings (via hasmapto() ), plugins can also define a default mapping if none was specified by the user. 由于Vim允许检查现有的映射(通过hasmapto() ),如果用户没有指定插件,插件也可以定义默认映射。

TL;DR TL; DR

  • for your own personal mappings, you can ignore <Plug> 对于您自己的个人映射,可以忽略<Plug>
  • if you use a plugin and need to customize its mappings, :map your own left-hand side to the <Plug> -mapping(s) provided by the plugin 如果您使用插件并需要自定义其映射,请:map您自己的左侧映射到插件提供的<Plug> --mapping(s)
  • if you write a plugin, enable user customization as described in :help using-<Plug> 如果您编写插件,请按照以下所述启用用户自定义:help using-<Plug>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM