Sometimes I use Command-T to browse files. When I find the file I needed, I would like to switch the current working directory to the opened file's directory. How can I do this?
1 Answer
:cd %:h
Explain:
:cd
change directory Vim command
%
- full path to current file
%:h
- full path to current file without filename itself.
See :help expand
and :help :cd
for more information
-
2
-
-
1Additionally, the setting
autochdir
can be set in.vimrc
to perform this action automatically. Apr 17, 2020 at 14:30