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?
相关问题
- Emacs shell: save commit message
- How to change the first two uppercase characters o
- Insert text into current buffer from function
- Hot reload on save
- Substituting zero-width match in vim script
相关文章
- 如何让 vim 支持 .cshtml 文件的代码高亮
- Auto-save in VIM as you type
- How can I use gcc's -I command to add recursiv
- Vim: overloaded mapping for multiple modes
- How to use relative line numbering universally in
- How to copy the value of a vim option to a registe
- E185: Cannot find color scheme*
- How do I fix vim to properly indent folds containi
As already suggested, you can use autochdir, which will change to the directory of the file you opened, the other option is
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.will change directory to your home directory (or on windows, print the current directory).
will change the directory to the previous directory you visited.
Also if you are browsing the filesystem with the netrw file explorer you can set the current directory by pressing the c key.
I don't know what is wrong with vim. I want the directory where I start up vim as the current.
I have followed the tip about autochd above and set that to noautcd in my .vimrc.
I haven't done it yet, but I am about to start up vim like this from now on:
That will make it stick to the current directory!
With
netrw:
in addition to pressing the c key to set the current directory, you may also put:in your
.vimrc
; this means thatnetrw
will keep the browsing directory the same as the current directory.Try adding
set autochdir
to your.vimrc
. If you want to change it just this once, use:cd
(or:cd!
to force it).Adding this to my
.vimrc
automatically changes Vim's working dir to the current file: