vim is showing a different current working directory than the one I started vim with from the command-line. The problem goes away if I run without my
vim -u NONE). How can I debug this to figure out why this is happening?
$ pwd /Users/rbednark/Dropbox/git/quizme_personal_files/bin $ vim --noplugin :pwd /Users/rbednark/Dropbox/git/quizme_personal_files/bin :edit settings.sh :pwd /Users/rbednark/quizme-read-only-prod (expected: /Users/rbednark/Dropbox/git/quizme_personal_files/bin actual: /Users/rbednark/quizme-read-only-prod )
The problem goes away if I don’t use my
$ vim -u NONE
:verbose set autochdir?outputs
:pwdboth output the same directory
.vimrclately (other than adding some comments). It’s under version control in git, so I confirmed these have been the only changes.
.bashrcbut nothing that I think would change vim behavior.
EDIT: I initially thought this was due to doing
:edit other-file, but now I see it with just editing a single file, so I changed the above to remove that unnecessary aspect.
Reason: I had done an
:lcd at some point, and my
loadview when leaving and entering a buffer, so editing the file again was doing an
:lcd to the other directory.
option 1 -- change the current working directory to the directory of the file being edited, and save:
cd %:p:h :wq
option 2 -- remove the corresponding view file, e.g.,
$ rm ~/.vim/view/*myfile*
How I solved / debugged:
I bisected my
.vimrc file to determine the offending line,
autocmd BufWinEnter * silent! loadview
That indicated it was due to a view that was getting loaded. I then viewed the corresponding
view file in
~/.vim/view and searched for the directory name, which yielded this line:
Correct answer by Rob Bednark on January 13, 2021
1 Asked on December 30, 2021
2 Asked on December 22, 2021 by songcheng-li
0 Asked on December 16, 2021 by henrique-barcelos
1 Asked on December 16, 2021
0 Asked on December 16, 2021
1 Asked on December 14, 2021 by paul-rougieux
0 Asked on December 14, 2021 by haris-muzaffar
1 Asked on November 27, 2021
3 Asked on November 22, 2021
2 Asked on November 20, 2021
3 Asked on November 17, 2021
Get help from others!