Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gvim netrw windows g:netrw_scp_cmd - transparent remote file editing does not work over scp #3762

Open
j86989 opened this issue Jan 4, 2019 · 5 comments
Assignees

Comments

@j86989
Copy link

j86989 commented Jan 4, 2019

Hi,

I've finally found out that netrw replaces colon with slash in path to a temporary file and inserts slash at the beginning of the path. Consequently, the content of remote file cannot be copied to local temporary copy over scp on windors.

Path to temporary file (tmpfile) is modified here:

vim/runtime/autoload/netrw.vim

Lines 2101 to 2103 in 7f1664e

if g:netrw_scp_cmd =~ '^scp' && (has("win32") || has("win95") || has("win64") || has("win16"))
let tmpfile_get = substitute(tr(tmpfile, '\', '/'), '^\(\a\):[/\\]\(.*\)$', '/\1/\2', '')
else

I have no idea when the path substitution helps but it may be really annoying when you use scp utility and its directory is added to PATH environmental variable.

let g:netrw_scp_cmd  = 'scpg3.exe -q' " Tectia Client

Workaround

It works when you undo substitutions in temporary file path.
Insert this line in autoload/netrw.vim file in if statement after substitution.

let tmpfile_get = tmpfile

but it's probably better to modify the condition in if statement...

@LKI
Copy link

LKI commented Dec 22, 2019

Same issue here.

Reproducing:

  1. Run :edit scp://host//linux_path
  2. Vim will run scp /linux_path /windows_path
  3. But windows path is substituted, which is something like /C/Users/me/AppData/Local/Temp/nonce.file

@LKI
Copy link

LKI commented Dec 22, 2019

Another workaround is change:

vim/runtime/autoload/netrw.vim

Lines 2101 to 2103 in 7f1664e

if g:netrw_scp_cmd =~ '^scp' && (has("win32") || has("win95") || has("win64") || has("win16"))
let tmpfile_get = substitute(tr(tmpfile, '\', '/'), '^\(\a\):[/\\]\(.*\)$', '/\1/\2', '')
else

To:

 if g:netrw_scp_cmd =~ '^scp' && (has("win32") || has("win95") || has("win64") || has("win16")) && !has("gui_running")
   let tmpfile_get = substitute(tr(tmpfile, '\', '/'), '^\(\a\):[/\\]\(.*\)$', '/\1/\2', '') 
 else 

@EdwinWenink
Copy link

EdwinWenink commented Dec 20, 2022

Encountered this exact issue on Windows using gVim, LKI's solution worked for me. Is there a way to solve this without editing autoload/netrw.vim? For example, is there a way to apply this hotfix from my user's vim configuration so I can put it under version control?

@chrisbra
Copy link
Member

ping @cecamp

@EdwinWenink
Copy link

The discussion at #5199 seems to be related

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants