如何使用powershell中的vim编辑UNC路径上的文件?

Eri*_*nau 5 windows powershell vim

尝试使用 vim 编辑 UNC 路径上的文件时出现以下错误。我该如何解决?

> new-psdrive x filesystem \\192.168.1.1\c$
> cd x:\
> vim .\test.txt
'\\192.168.1.1\c$'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.
Run Code Online (Sandbox Code Playgroud)

Jim*_*meh 3

如果您使用 vim.bat 启动 vim,它会启动 cmd.exe 并从那里运行 vim.exe。cmd.exe 不喜欢 UNC 路径,除非您像其他人建议的那样禁用检查。Powershell 不要求您禁用此功能。

你想要做的就是始终启动 vim,如下所示:

   vim.exe .\test.text
Run Code Online (Sandbox Code Playgroud)

或者,删除 vim.bat(通常在 C:\Windows\system32 中创建)并确保 vim.exe 在您的 $Path 中。