2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Windowsのgvimでリモートファイルをnetrwで開く

Posted at

背景

windowsのgvimでリモートファイルをnetrwで開こうとしたらエラーが出た。

前提

リモートサーバにパスなしのカギでsshできること

原因

gvim scp://server/filename

とすればリモートのファイルを開くことができるはずだが、できない。
netrwから呼ばれるscpコマンドが

scp -q "server:filename" "/C/Users/user/AppData/Local/Temp/****.tmp"

となっているが、Windows10標準で搭載されているSCPコマンドではこのPathを解釈できていないっぽい。これはmsysでビルドされたSCP用の仕様らしい。
https://github.com/vim-jp/issues/issues/635

解決策

\vim81\autoload\netrw.vim
をバックアップとってから書き換える

2099行あたりを下記のようにコメントアウト

    " 'C' in 'C:\path\to\file' is handled as hostname on windows.
    " This is workaround to avoid mis-handle windows local-path:
    "if g:netrw_scp_cmd =~ '^scp' && (has("win32") || has("win95") || has("win64") || has("win16"))
    "  let tmpfile_get = substitute(tr(tmpfile, '\', '/'), '^\(\a\):[/\\]\(.*\)$', '/\1/\2', '')
    "else
    let tmpfile_get = tmpfile
    "endif

お願い

netrw.vimを書き換える以外の方法をご存じの方がいればコメントをお願いいたします。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?