Reputation: 2877
I have an ssh connection to a remote machine in my terminal window, and GVim running locally as my text editor. I can mount the remote machine via SSH and open files in my local Vim. I can also edit remote files in my local Vim via Vim's support for editing over SCP.
Say I then use ag
on the remote machine to search my project for a symbol:
[user@remote project]$ ag thingy
include/blah/foo.h
1137:void thingy() {
Now what can I type inside my SSH session to send that file to my local editor in a tab? If I were on my local machine, I could do something like gvim -p --remote-tab-silent include/blah/foo.h
, but I don't think the Vim +clientserver
Remote system can be forwarded over an SSH session, can it? Would it somehow magically work if I set up X11 forwarding? If so, how would Vim work out what remote server to connect to to edit the file? Is there maybe some kind of integration between a vim-embedded terminal session and the netrw
system that I could use instead?
If I wanted to roll my own system with shell scripts and netcat and forwarding sockets of some kind over ssh, how might I design that?
Upvotes: 0
Views: 998
Reputation: 76549
The +clientserver
mechanism on Linux and Unix systems uses X11:
The communication between client and server goes through the X server. The display of the Vim server must be specified. The usual protection of the X server is used, you must be able to open a window on the X server for the communication to work. It is possible to communicate between different systems.
If you set up X forwarding properly, you should be able to open the file, although I haven't tested. That means that the remote system should have a $DISPLAY
environment variable.
If you haven't specified the server name explicitly, it is usually in the title bar of the window. The first one, on my Debian system, is GVIM
, the next is GVIM2
, etc. Client/server arguments need to go on the command line in a specific order and first on the command line. I'd try setting this up on a local machine and only then trying it with the remote machine.
Upvotes: 1