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:

  1. Vim should automatically switch the working directory to where the the current file is located.
  2. 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 %

Comments

comments powered by Disqus