【问题标题】:Is it possible to make vim use forward slashes on windows?是否可以让 vim 在 Windows 上使用正斜杠?
【发布时间】:2013-08-30 02:50:02
【问题描述】:

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

:vimgrep /Foo/ src/*

工作得很好,但是

:vimgrep /Foo/ src\*

没有,因为\ 转义了*。手动我只是写正斜杠,但制表符完成总是在最后给我反斜杠,所以我必须一直更改它。

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

【问题讨论】:

    标签: windows vim configuration path


    【解决方案1】:

    这应该做你想做的事

    :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')
    

    【讨论】:

    • 但是请注意,'shellslash' 会破坏一些外部程序、许多插件和 shellescape() 函数。因此,如果您开始使用这些功能中的任何一个出现奇怪的错误,请通过禁用该选项来查看它是否会消失。如果插件...通知插件作者。
    猜你喜欢
    • 2013-11-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多