[英]How to Run Vim Commands When Opening File
How can I have vim commands at the top of a file, like the shebang convention?如何在文件顶部使用 vim 命令,例如 shebang 约定? An example is best:一个例子是最好的:
#/usr/bin/env python3
#v set textwidth=70
print("Hello")
In this example, Vim would look for a comment starting with #v
, and execute the following command.在此示例中,Vim 将查找以#v
开头的注释,并执行以下命令。
TL;DR: how can I make Vim run specific commands by opening a file, not linked to a file type, and not by adding lines to my init.vim
? TL;DR:我怎样才能让 Vim 通过打开文件运行特定命令,而不是链接到文件类型,而不是通过向我的init.vim
添加行来运行特定命令? Plugins are also an option.插件也是一种选择。
You are looking for:您正在寻找:
:help modeline
Note that adding self-serving modelines to files in a shared project is generally seen as pollution and frowned upon.请注意,向共享项目中的文件添加自助服务模式通常被视为污染并且不受欢迎。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.