Ricardo
Ricardo

Reputation: 597

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.

Upvotes: 0

Views: 110

Answers (1)

sudo bangbang
sudo bangbang

Reputation: 28219

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.

Upvotes: 2

Related Questions