Score:0

Local .vimrc doesn't get executed when I run vi

za flag

I read from here that when I run vi in a local directory where I have a local .vimrc file, the commands in that .vimrc takes effect. But when I try it, it doesn't work for me.
Here is the test I did.

  1. In my ubuntu-20.04, I make a directory ~/testdir11, and testdir22 under that testdir11(~/testdir11/testdir22).
  2. Then I make a file ~/testdir11/.vimrc and put 'set path+=testdir22' in that .vimrc file.
  3. And I make a file ~/testdir11/test.txt and put 'include "xyz.h"'
  4. make ~/testdir11/testdir22/xyz.h and fill it with 'This is a test file'.
  5. now in directory ~/testdir11, I do 'vi test.txt' and when the cursor is on xyz.h, I press 'gf'. This should open xyz.h because the .vimrc has 'set path+=testdir22' and the xyz.h file is in testdir22 directory. But in my case it doesn't go to that xyz.h file.

What is wrong with my setup? (If I put 'set path+=testdir22' in ~/.vimrc, it works).

ADD :
I tried :source .vimrc and it works. But I'm still curious why reading local .vimrc seems to work for other people.(in the link I've shown above..)

muru avatar
us flag
"I read from here that when I run vi in a local directory where I have a local .vimrc file, the commands in that .vimrc takes effect." You do understand that post is asking how this can be accomplished and this doesn't happen automatically? It'd be a security nightmare if this were some feature enabled by default. Did you add any of the configuration suggested by the answers to enable it?
za flag
@muru I saw `localvimrc` but it's not exactly what I want. I want path and tags information relative to where I open the file, not the file's location. I'll check other options later(because it's not urgent). thank you.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.