Question

Vim associates some default working directory to opened files when I work on multiples files under different directories in a single vim windows.

I have traced back the problem to my fold settings as I found a lcd comment in the .vim/view/ file relating to the problem files. When deleted the problem is resolved.

As an example consider my ~/opt/lib/python/peakdetect.py file, its ~/.vim/view/~\=+opt\=+lib\=+python\=+peakdetect.py\= contains the following line:

lcd ~/mnt/CASE\ STUDIES/amazon\ -\ employee\ access
let &so = s:so_save | let &siso = s:siso_save
doautoall SessionLoadPost

How can I prevent this behaviour?

Here's my .vimrc (.gvimrc only sets window size) options relating to the fold:

" save & load fold structure
 42 au BufWinLeave * silent! mkview
 43 au BufWinEnter * silent! loadview
 44 set fdo-=search "do not open close fold when matching
 45 set fdo-=block "do not open closed but when using z? commands

Thanks

Was it helpful?

Solution

What gets persisted is determined by the 'viewoptions' setting. Unfortunately, there's no separate configuration value for the local working directory. It seems that Vim always adds the :lcd command when you've set a local one.

To work around this, either avoid creating views for windows that currently have a window-local directory, or you could post-process the generated view script to remove / comment out the :lcd line. The session.vim plugins uses that approach for session files.

OTHER TIPS

set sessionoptions-=curdir

This setting also applies to views although the documentation doesn't say anything about that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top