Skip to main content
added 786 characters in body
Source Link

I saw something strange happen today. I was in directory /some/path/ and opened a file with vim file.html.

I then did :pwd in vim and it gave me /some/other/path. What could cause this to happen?

EDIT: :verbose set autochdir? outputs noautochdir

EDIT2: putting set autochdir in ~/.vimrc doesn't solve it.

I tried this:

  1. cd /dir1/
  2. vim dir2/newfile
  3. :pwd -> /dir1/
  4. cd /dir1/dir2/
  5. vim newfile
  6. :pwd -> /dir1/dir2/

This is the behavious I expect (:pwd returning the directory in which I launched vim) so I don't understand why for one particular file it doesn't work like that.

I figured it must be somehow caused by It is definitely caused by these lines in ~/.vimrc:

autocmd BufWinLeave * mkview
autocmd BufWinEnter * silent loadview

I deleted my ~/.vimrc and :pwd returned the correct directory.

After I restored it, the situation reverted to the original problem. I still don't understand how it happenned, I can't recreate the issue.

I saw something strange happen today. I was in directory /some/path/ and opened a file with vim file.html.

I then did :pwd in vim and it gave me /some/other/path. What could cause this to happen?

EDIT: :verbose set autochdir? outputs noautochdir

I saw something strange happen today. I was in directory /some/path/ and opened a file with vim file.html.

I then did :pwd in vim and it gave me /some/other/path. What could cause this to happen?

EDIT: :verbose set autochdir? outputs noautochdir

EDIT2: putting set autochdir in ~/.vimrc doesn't solve it.

I tried this:

  1. cd /dir1/
  2. vim dir2/newfile
  3. :pwd -> /dir1/
  4. cd /dir1/dir2/
  5. vim newfile
  6. :pwd -> /dir1/dir2/

This is the behavious I expect (:pwd returning the directory in which I launched vim) so I don't understand why for one particular file it doesn't work like that.

I figured it must be somehow caused by It is definitely caused by these lines in ~/.vimrc:

autocmd BufWinLeave * mkview
autocmd BufWinEnter * silent loadview

I deleted my ~/.vimrc and :pwd returned the correct directory.

After I restored it, the situation reverted to the original problem. I still don't understand how it happenned, I can't recreate the issue.

added 57 characters in body
Source Link

I saw something strange happen today. I was in directory /some/path/ and opened a file with vim file.html.

I then did :pwd in vim and it gave me /some/other/path. What could cause this to happen?

EDIT: :verbose set autochdir? outputs noautochdir

I saw something strange happen today. I was in directory /some/path/ and opened a file with vim file.html.

I then did :pwd in vim and it gave me /some/other/path. What could cause this to happen?

I saw something strange happen today. I was in directory /some/path/ and opened a file with vim file.html.

I then did :pwd in vim and it gave me /some/other/path. What could cause this to happen?

EDIT: :verbose set autochdir? outputs noautochdir

Source Link

Working directory different than current file directory?

I saw something strange happen today. I was in directory /some/path/ and opened a file with vim file.html.

I then did :pwd in vim and it gave me /some/other/path. What could cause this to happen?