2012-12-20 50 views
3

我採購使用插件從這裏第一響應本地的vimrc:Vim: apply settings on files in directory獲取當前文件的路徑被採購

現在我想要做的是什麼這個本地vimrc文件的CURREN路徑添加到vims路徑。

我知道%:p:h給我當前文件的路徑。但是它的文件被打開,而不是被配置文件被打開。

let s:local_path = expand('%:p:h') 
exec "set path+=".s:local_path 

有誰知道如何獲取文件的路徑來源?

+0

請更準確地解釋您的目標。 – romainl

+0

[如何獲取正在執行的當前vimscript的路徑]的可能重複(http://stackoverflow.com/questions/4976776/how-to-get-path-to-the-current-vimscript-being-executed) –

回答

2

而不是%,只需使用特殊的<sfile>;在腳本中(但不在腳本中的函數內),它會擴展爲源腳本的文件名:

:let s:local_path = expand('<sfile>:p:h')