Vim: Change start up directory?
Solution 1
Assuming you're starting gvim from an icon/shortcut in Windows (from the kind of paths you supply), you can change the starting directory (completely independent from the fact that it IS gvim: it would be the same from any other app!) by editing the "starting directory" property of that Windows icon/shortcut.
Solution 2
Within vim, you can change the current directory with the :cd
command:
:cd c:\users\casey
Solution 3
I found this way to be better:
- Open gVim
:cd $vim
:e _gvimrc
Add the following line:
:cd c:\users\user\desktop\
I found that :Ex
is slow on large directories like c:\windows\system32\ (where gVim usually starts).
Also, here is my full _gvimrc in case anyone is interested. I prefer Consolas for coding. The tabstop setting helps when coding especially in Python, and Ctrl+Tab/Ctrl+Shift+Tab is great for switching between buffers:
set guifont=Consolas:h12:cANSI
set tabstop=4 softtabstop=4 shiftwidth=4 expandtab
map <C-Tab> :bnext<cr>
map <C-S-Tab> :bprevious<cr>
:cd c:\users\user\desktop\
Solution 4
How about changing your starting position?
vim icon -> right click -> property -> shortcut -> Start in -> your path you want to change.
but it works perfectly.
I think :cd yourpath also works. but it will change when you don't want to change.
Solution 5
I found the following to be very useful. I am on Windows 7 and vim 7.3.46, and am using gVim.
I edited startup settings, which wound up altering the _vimrc in c:\Users\me\
.
I also tried using :version
and editing the _vimrc files I found at $VIM
, as well as the _vimrc
I found at c:\windows\system32
.
Editing those files to include :cd c:\Users\me
did not result in my default startup directory changing after starting vim. I wanted my default directory to be c:\Users\me\
, and editing c:\Users\me\_vimrc
achieved that. That is I entered
:e $MYVIMRC
and added
cd c:\Users\cnorton.Arlington1\
to that file.
Nope
Updated on December 05, 2020Comments
-
Nope over 3 years
When I start GVim and start writing my little program I'd like to save the file to the Desktop but it seems that Vim is starting the command line in:
C:\Windows\System32
How would I go about changing that to:
C:\Users\Casey
so then I could just:
:w Desktop\my_program.py
Thank you