I use the :find command to find files in vim
. My path is set like so:
set path=$PWD/**
This works well until I use :Explore
and the c
mapping to update the CWD at which point the PWD and CWD are no longer the same. I need to set the path again after each directory change. Does anyone have a solution to this problem?
P.S.
No plugins allowed =p
Select a file or directory name and press Enter to open that file or directory. (For example :e /home/user displays the contents of that directory.) To return to the explorer window, press Ctrl-^ (usually Ctrl-6). You can also "edit" a directory to explore that directory.
cwd is short for “current working directory”. Every command you run has its own current working directory. When you start a terminal emulator, your first cwd is your home directory ( /home/user ), and then you can use cd to change the working directory.
You can use the following command to update your 'path'
option to the CWD.
let &path = getcwd() . '/**'
Unfortunately, there's no event for directory changes to hook into. You could either:
c
mapping in the netrw windows, with :autocmd FileType netrw nnoremap <buffer> c ...
:autocmd WinEnter,CursorHold ...
and invoke the above command then.I think you need the autochdir
to set on:
'autochdir' 'acd' boolean (default off)
global
{not in Vi}
{only available when compiled with it, use
exists("+autochdir") to check}
When on, Vim will change the current working directory whenever you
open a file, switch buffers, delete a buffer or open/close a window.
It will change to the directory containing the file which was opened
or selected.
This option is provided for backward compatibility with the Vim
released with Sun ONE Studio 4 Enterprise Edition.
Note: When this option is on some plugins may not work.
But this is buggy if you using netrw
or fugitive
for example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With