简体   繁体   中英

How to Run Vim Commands When Opening File

How can I have vim commands at the top of a file, like the shebang convention? 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.

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 ? 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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