Is it possible to make vim use forward slashes on windows?

99封情书 提交于 2019-12-22 05:34:08

问题


Native build of ViM on Windows uses backslashes in file paths including for completion, though it works fine if I use forward slashes manually (in fact all Windows API understand them, cmd.exe is the only exception) and backslashes cause various problems, because they double as escape and the "dwim" logic does not really work. For example:

:vimgrep /Foo/ src/*

works just fine, but

:vimgrep /Foo/ src\*

does not, because the \ escapes the *. Manually I just write forward slash, but tab completion always gives me backslash at the end, so I have to change it all the time.

Is it possible to reconfigure ViM to use forward slashes by default (preferably without recompiling it)?


回答1:


This should do what you want

:set shellslash

Help (:h shellslash) copied below

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


来源:https://stackoverflow.com/questions/18464038/is-it-possible-to-make-vim-use-forward-slashes-on-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!