如何在 Vim 中设置工作/当前目录? [英] How to set working/current directory in Vim?

查看:37
本文介绍了如何在 Vim 中设置工作/当前目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,当我想使用 :e 命令创建新文件时,我不想指定整个路径,而只想指定新文件名.可以吗?

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?

推荐答案

正如已经建议的,您可以使用 autochdir,它会切换到您打开的文件所在的目录,另一个选项是

As already suggested, you can use autochdir, which will change to the directory of the file you opened, the other option is

:cd mydirectory

这将改变目录.这可以是绝对路径或相对路径,因此 :cd .. 将向上移动一级.或者您可以使用 :cd %:h ,它也会更改到当前文件所在的目录,但不设置 autochdir.

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

将目录更改为您的主目录(或在 Windows 上,打印当前目录).

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.

这篇关于如何在 Vim 中设置工作/当前目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆