vimtext-editorpwd

vim - how to set fix path as working directory


I have this issue. Let's suppose I have the following directory tree:

diffchar/
├── README.md
├── autoload
│   └── diffchar.vim
├── demo.gif
├── doc
│   ├── diffchar.txt
│   └── tags
├── example1.png
├── example2.png
└── plugin
    └── diffchar.vim

If I open diffchar.vim under autoload, the working directory will be set to /path/to/diffchar/autoload. I explicitly specify :cd /path/to/diffchar, but if I open diffchar.txt, the working directory will be set to /path/to/diffchar/doc.

Any idea how to set the working directory to a fix path and that it does not change when I open files under different directories?


Solution

  • You probably have autochdir (see here) set to on. Check with this vim command

    :set autochdir?
    

    If the output just says autochdir and not noautochdir, then you have it set. Turn it off by doing:

    :set autochdir !