是否可以使vim在Windows上使用正斜杠? [英] Is it possible to make vim use forward slashes on windows?
问题描述
Windows上的本机ViM本地版本在文件路径中使用反斜杠(包括完成字符),但是如果我手动使用正斜杠(实际上所有Windows API都理解它们,cmd.exe
是唯一的例外)会很好用,反斜杠会引起各种问题,因为它们兼作转义符,并且"dwim"逻辑实际上不起作用.例如:
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/*
工作正常,但是
: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.
是否可以将ViM重新配置为默认使用正斜杠(最好不重新编译)?
Is it possible to reconfigure ViM to use forward slashes by default (preferably without recompiling it)?
推荐答案
这应该做您想要的
: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')
这篇关于是否可以使vim在Windows上使用正斜杠?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!