How to use file explorer on my local gVim to access remote file system?

345 views
Skip to first unread message

Igor Forca

unread,
Nov 12, 2018, 3:09:52 AM11/12/18
to vim_use
Hi,
I am using latest gVim v8.1.0513 nightly build on Windows 7, both 64-bit.

I have several Linux machines accessible using ssh. Now I am using local machine's Vim through Putty on every machine. But there are several problems, there are different versions on Vim (some pretty old one) and there are different vim settings, different syntax highlighting etc and there is sometimes even lack of responsiveness and similar.

On my Windows I have gVim customized to my wishes.

From my Windows PC's gVim I would like to access files on remote Linux machines, edit and save. On my PC I have created text file with the following commands:

let g:netrw_silent = 1
let g:netrw_scp_cmd = "\"C:\\Programs\\PuTTY\\pscp.exe\" -pw mypassword "
e scp://myus...@192.168.1.20//path/to/file.txt

When I open a gVim on Windows I can source that file:
:source commands.vim

and file.txt from remote machines is opened, I can edit it and save changes it works perfectly for individual file.

Now to the problem. I have hundreds of files that I need to edit. So it would be way more convenient to open file explorer for remote file system.
On my local machine to access my local PC's files I can open file explorer with command: :E
How to do this for remote machine?

I looked into commands.vim and changed the last line to:
e scp://myus...@192.168.1.20//path/

but I get the error:
**error** (netrw) your g:netrw_list_cmd is empty; perhaps ssh is not executable on your system

Any idea how to use file explorer on remote machine accessed from my local gVim?

Thanks

Tony Mechelynck

unread,
Nov 12, 2018, 3:36:51 AM11/12/18
to vim...@googlegroups.com
It may depend on the configuration of your remote server: depending on
how you can access it, it may or may not allow you access to the
directories of its folders. If you have ftp access (possibly with
username and password), then directories are usually available. For
other access modes (http, scp, etc), I don't know.

See also:
:help g:netrw_ftp_cmd
:help netrw-windows-netrc (for Windows only)
:help netrw-netrc (usually not for Windows)

Best regards,
Tony.

Igor Forca

unread,
Nov 12, 2018, 4:09:29 AM11/12/18
to vim_use
Tony,
this server does not have FTP installed and admin does not permit installing it.

I have now tested on my "Ubuntu 18.04 desktop" PC machine (not used frequently) with vim 8.0.1766 installed and executed only one command:
:e scp://myus...@192.168.1.20//path/
and file explorer opened without a problem and I can use arrow keys to select file and file is opened successfully. (The only tiny problem is it asks for password for every task I execute, but this is expected, because no password related settings are set). So there is probably no directory listing problem on this remote server.

It looks like a Windows specific problem. Maybe some additional setting is required or something?
Regards

Tony Mechelynck

unread,
Nov 12, 2018, 4:53:06 AM11/12/18
to vim...@googlegroups.com
For scp it seems (from the netrw documentation) that the problem is
not even Windows-related, see :help netrw-passwd §2. But there is
there a link to :help netrw-ssh-hack — maybe that can help you… ah,
about 1½ screen lower than that there is a paragraph starting "For
Windows users". The rest may or may not be applicable to you.

Best regards,
Tony.

Ken Takata

unread,
Nov 12, 2018, 5:12:04 AM11/12/18
to vim_use
Hi,

So, did you set g:netrw_list_cmd?
If not try setting it.
E.g. https://stackoverflow.com/a/8996320
> let g:netrw_list_cmd = "plink.exe -P ##### -pw MyPass us...@host.com ls -Fa "


Regards,
Ken Takata

Igor Forca

unread,
Nov 12, 2018, 6:35:49 AM11/12/18
to vim_use
@Ken, thanks a lot that it! Problem solved. Now I can open files and folders.
Just for reference, the final code is:

let g:netrw_silent = 1

let g:netrw_list_cmd = "C:\\Programs\\PuTTY\\plink.exe -P 22 -pw password use...@192.168.1.20 ls -Fa "
let g:netrw_scp_cmd = "C:\\Programs\\PuTTY\\pscp -P 22 -pw password -scp "
e scp://use...@192.168.1.20//path/to/dir/

aro...@vex.net

unread,
Nov 12, 2018, 9:31:05 AM11/12/18
to vim...@googlegroups.com
>
> Now to the problem. I have hundreds of files that I need to edit.

That doesn't sound a situation a human being should have to grind through.
Is there any possibility of automating the process, using something like sed?


Reply all
Reply to author
Forward
0 new messages