简体   繁体   中英

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. So, I tried to put the following line into an empty ~/.vim/vimrc file:

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.

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 . If I launch :scriptnames I see a lot of scripts that are executed after my code, therefore I suppose textwidth is overwritten.

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.

One way to get around this is to use after directory. Create a file ~/.vim/after/ftplugin/text.vim

Add your code to this file. Vim will load this script after it loads plugins.

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