Vim - Adding another folder to current session
January 6, 2021 by Kinh Nguyen
To mimic project-like feature in Sublime Text or Visual Studio Code, that is
multiple folders are available in search path. This helps the autocomplete of
functions like buffer, edit,… find out all intended locations.
The approach is:
- Vim should automatically switch the working directory to where the the current file is located.
- The new folder is added automatically to the search path
These are equivalent to adding these to ~/.vimrc
- Adding
set autochdir - Adding
autocmd BufRead *.* set path+=
Needless to say, save and reload the configuation with :w | so %