2013-08-27 35 views
4

ViM在Windows上的本地構建在文件路徑中使用反斜槓(包括完成),但如果手動使用正斜槓(實際上所有的Windows API都理解它們,cmd.exe是唯一的例外),反斜槓會導致各種問題,雙重逃脫並且「dwim」邏輯不起作用。例如:是否有可能使vim在Windows上使用正斜槓?

:vimgrep /Foo/ src/* 

工作得很好,但

:vimgrep /Foo/ src\* 

沒有,因爲\逃脫*。手動我只寫正斜槓,但製表符總是在最後給我反斜槓,所以我必須一直改變它。

是否可以重新配置ViM以默認使用正斜槓(最好不要重新編譯它)?

回答

8

這應該做你想做的

:set shellslash 

幫助(:h shellslash)複製下面然而

     'shellslash' 'ssl' 'noshellslash' 'nossl' 
'shellslash' 'ssl'  boolean (default off) 
         global 
         {not in Vi} {only for MSDOS, MS-Windows and OS/2} 
     When set, a forward slash is used when expanding file names. This is 
     useful when a Unix-like shell is used instead of command.com or 
     cmd.exe. Backward slashes can still be typed, but they are changed to 
     forward slashes by Vim. 
     Note that setting or resetting this option has no effect for some 
     existing file names, thus this option needs to be set before opening 
     any file for best results. This might change in the future. 
     'shellslash' only works when a backslash can be used as a path 
     separator. To test if this is so use: 
       if exists('+shellslash') 
+1

注意的是,了 'shellslash' 打破一些外部程序,很多插件和shellescape ()函數。因此,如果您開始使用這些功能獲得奇怪的錯誤,請通過禁用該選項來查看它是否消失。如果插件...通知插件作者。 – Ben

相關問題