egabs
egabs

Reputation: 21

vim uses a different rc file for 2 different files in the same folder. How come?

I have 2 text files: file1.txt and fil2.txt in my home directory. I am using /usr/bin/vim to open both of them. When looking to find which is the last script used to set the attributes (e.g. :verbose set textwidth?) they yield different results. How come ? Where is that info stored ?

vim file1.txt

:verbose set textwidth?
  textwidth=78
        Last set from /etc/vimrc

vim file2.txt

:verbose set textwidth?
  textwidth=120
        Last set from ~/.exrc

Just to add to the puzzle or maybe help with getting the answer: if I copy file2.txt to a new file (i.e. file3.txt) then the new file gets "Last set from /etc/vimrc"):

cp file2.txt file3.txt
vim file3.txt
:verbose set textwidth?
  textwidth=78
        Last set from /etc/vimrc

Here is a more info on the new file3.txt I just created: The Xterm where I created the new file3.txt shows "Last set from /etc/vimrc" on the other hand if I go into another Xterm (let's call it Xterm2) I had opened a while ago and check on the file3.txt it shows "Last set from ~/.exrc". So the answer has to be related to the Xterm env settings as well. To summarize:

Xterm file2.txt -> ~/.exrc
Xterm file3.txt -> /etc/vimrc
Xterm2 file2.txt -> ~/.exrc
Xterm2 file3.txt -> ~/.exrc

Upvotes: 2

Views: 190

Answers (2)

gregory
gregory

Reputation: 12973

.exrc is the configuration file for vi, 
.vimrc is the config file for vim

So, file1.txt was edited and saved in vim; file2.txt was edited and saved in vi. (Note: vim will use .vimrc configuration file, but if it doesn't exist, it will resort to .exrc.)

textwidth=xxx is a configuration that you can put in the .vimrc or .exrc config file.

Upvotes: 0

Where is that info stored ?

For each option of set command (set [option]) vim is holding characteristics related to each one.

One of these characteristics, is the id of the script in which the last set was made.

So Vim does not hold that infomation in any file, it writes them directly on the screen.

If you have set the verbosefile option vim will copy those messages shown by verbose command according to the verboselevel in a file.

When looking to find which is the last script used to set the attributes (e.g. :verbose set textwidth?) they yield different results. How come ?

You need to check your /etc/vimrc, ~/.exrc, plugins and sourced files to know the order that was made to set textwidth option so you can understand why it is the last script setting it.

Upvotes: 0

Related Questions