[英]Execute a line in vimrc at the end
I want to set textwidth
to 50 when a file in the form jrnl*.txt
is detected. 当检测到jrnl*.txt
格式的文件时,我想将textwidth
设置为50。 So, I tried to put the following line into an empty ~/.vim/vimrc
file: 因此,我尝试~/.vim/vimrc
下行放入一个空的~/.vim/vimrc
文件中:
au BufRead,BufNewFile jrnl*.txt set fo+=t tw=50
And it works correctly. 而且它可以正常工作。
However, I'm using now Vim-Boostrap , which is a vimrc
generator with a lot of plugins. 但是,我现在使用的是Vim-Boostrap ,这是一个带很多插件的vimrc
生成器。
I have tried to write my code at the end of the new vimrc
but when I a run vim, textwidth
is equal to 0
. 我试图在新vimrc
的末尾编写代码,但是当我运行vim时, textwidth
等于0
。 If I launch :scriptnames
I see a lot of scripts that are executed after my code, therefore I suppose textwidth
is overwritten. 如果启动:scriptnames
我会在代码后看到很多执行的脚本,因此我认为textwidth
被覆盖了。
I wonder if there is a method to execute my line at the end and thus avoid the overwritten issue. 我想知道是否有一种方法可以在最后执行我的行,从而避免覆盖问题。
Your hypothesis that plugins are overriding your settings is probably right. 关于插件将覆盖您的设置的假设可能是正确的。 Putting your code at the end of vimrc
would also not help as vimrc
is loaded before plugins. 将代码放在vimrc
的末尾也无济于事,因为vimrc
在插件之前加载。
One way to get around this is to use after directory. 解决此问题的一种方法是在after目录中使用。 Create a file ~/.vim/after/ftplugin/text.vim
创建一个文件~/.vim/after/ftplugin/text.vim
Add your code to this file. 将您的代码添加到此文件。 Vim will load this script after it loads plugins. Vim将在加载插件后加载该脚本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.