Gvim Current Directory
When I gvim a file from gnome, gvim’s working directory is always my home directory. That is not what I want. It is inconvenient for :vi , :r and :w something.else . Is there a way to automatically cause gvim’s current directory to be the directory of the edited file?
I am aware of workarounds involving the command line. I am aware of gedit. I am looking for a way to give gvim the correct working directory. Is this a gnome thing?
3 thoughts on - Gvim Current Directory
solved
Searching on “working directory” worked better than searching on “current directory”
In my ~/.vimrc file:
command CDC cd %:p:h
:CDC will do what I want.
I found it here:
http://vim.wikia.com/wiki/Set_working_directory_to_the_current_file
No, it’s not a GNOME thing. I assume you’re opening up gvim from a menu? Then your current working directory is $HOME. That’s the way unix/linux works when you start a program and your CWD is $HOME. The graphical interface has a CWD of $HOME, so anything it forks will too.
What I do is open a terminal session; cd to the working directory I
desire, and then run gvim from the command line.