Vim:e起始目录?

ano*_*non 15 vim

我在Vim中编码,而不是IDE.我的源代码经常嵌套2-3个目录.

~/foo$ find
xyz
bar/abc
bar/def

~/foo$ vim
// inside of vim
:e bar/abc
... some work ...
:e <-- is there a way I can have this :e start in ~/foo/bar instead of ~/foo ?
Run Code Online (Sandbox Code Playgroud)

基本上,我想:e在"最后编辑的文件的路径名"中启动目录

谢谢!

mic*_*ael 12

有很多理由不喜欢autochdir,因为它打乱了一些插件,如果你最终做:电子../../../foo.txt你没有得到什么.就像一个想法尝试这个cmap我敲了

:cnoremap red edit <c-r>=expand("%:h")<cr>/
Run Code Online (Sandbox Code Playgroud)

然后你可以输入:red和get

:e /the/path/to/your/current/files/dir/
Run Code Online (Sandbox Code Playgroud)

(编辑:也许使用z代替红色,因为有以红色开头的命令)

要扩展主题,还可以查看FuzzyFinder插件和一些自定义映射,以快速跳转到您始终编辑的常用文件.例如

10个左右的常规文件应该不超过2次击键.如果系统地命名它会有所帮助

这是我用于django的一个想法.

http://code.djangoproject.com/wiki/UsingVimWithDjango#Mappings


Dav*_*Ray 11

尝试autochdir选项.它会自动将当前工作目录更改为最近打开或选择的文件.在.vimrc中:

set autochdir
Run Code Online (Sandbox Code Playgroud)

有关更多信息, :help autochdir