So when I want to create a new file by using the :e command I don't want to specify the whole path, just the new filename. Can it be done?
+1
A:
Try adding set autochdir
to your .vimrc
. If you want to change it just this once, use :cd
(or :cd!
to force it).
John Feminella
2010-02-18 13:08:07
+10
A:
As already suggested, you can use autochdir, which will change to the directory of the file you opened, the other option is
:cd mydirectory
which will change the directory. This can be an absolute or relative path, so :cd ..
will move up one level. Or you can use :cd %:h
which will also change to the directory the current file is in, but without setting autochdir.
:cd
will change directory to your home directory (or on windows, print the current directory).
:cd -
will change the directory to the previous directory you visited.
roe
2010-02-18 13:11:08
awesome guys. thank you!
Jon
2010-02-18 13:14:28
if you're using multiple windows, you can even use :lcd to change directory for the current window only.
Useless
2010-02-18 13:59:45
@Useless: interesting... I don't think I'd ever want that, but I suppose that's a matter of taste. Thanks for the info.
roe
2010-02-18 14:12:21
A:
Also if you are browsing the filesystem with the netrw file explorer you can set the current directory by pressing the c key.
Dave Kirby
2010-02-18 17:29:29