My current workflow is often to do things in a terminal and open/change relevant files in a text editor.
Transitioning from VSCode to Emacs I am looking for a similar workflow that I got used to when using VSCode.
One of these things was navigating my directories in a VSCode terminal to search for the relevant file and simply opening it in the editor, i.e. code file.txt
, and proceed to make changes.
I experienced a similar workflow using Emacs term
, where I could simply navigate my folders and use C-x C-f
(or rather C-c C-f
when in the term
-buffer) to open file as it defaulted to the current directory of term
.
However, when trying out vterm
as I needed a better terminal emulato, I found that C-x C-f
does not default to the current directory in vterm
.
This means that I have to manually navigate to the file I want to open in Emacs, which can be quite cumbersome.
Is there a way to configure vterm
to export the current directory to the find-file
functionality of Emacs? Or should I use term
for simple directory navigation and vterm
for more complex terminal emulation?
dirtrack-mode
. Alternatively, you can enable the emacs server, and then useemacsclient <file>
from within vterm to edit files.dirtrack-mode
does not seem to work out of the box, butemacsclient <file>
does appear to work!dirtrack-mode
only works with modes derived fromcomint
, whichvterm
isn't. But I found a better option, which I'll add as an answer