when I open gvim using Alt+F2
it takes as its default working directory my home folder.
How can I change the working folder after or while running gvim? can i pass that folder as a parameter when open gvim?
Or you can use :cd %:h which will also change to the directory the current file is in, but without setting autochdir. will change directory to your home directory (or on windows, print the current directory).
Use e.g. From the docs: 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.
When you start vim, it gets the working directory of your shell. And then you can type commands like :e to open paths relative to your working directory. you can run :e bar. c to open a window containing the contents of the bar.
On Windows 10, the vim directory is located at %USERPROFILE\vimfiles , you may link it to any other directory through the mklink command.
You could use a shortcut.
The simplest way, though, would be to
:edit $MYVIMRC
append a line
cd /home/user/my/work/dir
save (optionally execute :w|source %
to immediately reload)
use
:pwd :cd some/other/dir
To view/change current working directory.
Use e.g.
:cd %:h
to change to the directory containing the file loaded in the active window. If you need/want to do this often, consider just setting 'autochdir'
:se autochdir
From the docs:
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.
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