Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 823
Jan Hudec Avatar asked Aug 27 '13 11:08

Jan Hudec


1 Answers

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')
like image 124
FDinoff Avatar answered Sep 16 '22 22:09

FDinoff