How to set working/current directory in Vim?

前端 未结 6 969
忘掉有多难
忘掉有多难 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:37

    Adding this to my .vimrc automatically changes Vim's working dir to the current file:

    autocmd BufEnter * silent! :lcd%:p:h
    

提交回复
热议问题