How to set working/current directory in Vim?

前端 未结 6 956
忘掉有多难
忘掉有多难 2020-12-04 09:42

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?

6条回答
  •  眼角桃花
    2020-12-04 10:40

    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.

提交回复
热议问题