8

Windows 上 ViM 的本机构建在文件路径中使用反斜杠,包括完成,尽管如果我手动使用正斜杠(实际上所有 Windows API 都理解它们,cmd.exe是唯一的例外)它工作正常,并且反斜杠会导致各种问题,因为它们兼作转义并且“dwim”逻辑并没有真正起作用。例如:

:vimgrep /Foo/ src/*

工作得很好,但是

:vimgrep /Foo/ src\*

不会,\因为*. 手动我只写正斜杠,但制表符完成总是在最后给我反斜杠,所以我必须一直改变它。

是否可以将 ViM 重新配置为默认使用正斜杠(最好不重新编译)?

4

1 回答 1

11

这应该做你想做的

: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')
于 2013-08-27T13:52:10.650 回答