5

Vim (actually, gvim is in question, but I believe it works both ways) upon starting has its current directory in its runtime directory.

I would like to upon starting, to have its cd in let's say, c:\pro
I know I can just do :cd c:\pro, but is there a way to change it upon starting it, with
something alike gvim c:\pro (only that doesn't work :-| ?

2 Answers 2

7

You can use

gvim -c "cd C:/pro" 

-c allows you to run commands just after Vim has finished loading.

Vim's working directory is initially set to the working directory of the process that invokes Vim.

If you're double-clicking on the .exe in Explorer, that's why it's the runtime directory.

If you're using the Start Menu shortcut, then it has the Start in path set to the runtime directory. You could change the Start in path of the shortcut.

If you use the run dialog, then vim's initial working directory is likely your Documents and Settings directcory.

Sign up to request clarification or add additional context in comments.

5 Comments

actually, i'm trying to get it to launch through launchy, with starting directory of my preference ...
Ok, then the -c suggestion will work. I just also wanted to make sure the method behind Vim's behavior was clear. :)
yeah ... except, i just noticed launchy doesn't take command line arguments ... rats :-(
According to their docs, they do: Launchy allows you to enter command line options into your queries. Simply hit tab once you have found the application you are interested in and then enter your command line options.
just found that out too (by accident) .. in any case .. thanks jamessan, you're a well of info ... (not the same one from #vim of freenode, by any chance ?)
0

Can't you put cd path in your .vimrc ?

2 Comments

it would cd you in path on startup, isn't that what you want?
the given directory in question was just an example. i wish to start gvim each time with a different directory ...

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.