0
votes

I am using ZOC, used Windows CMD as well, the same thing, when I highlight the text using VIM and run command like "+y or "*y, and then, try to paste in my Windows local editor, the output is blank, which makes me thinking, that the highlighted text has not being copied/delivered to the system clipboard through the SSH connection...

Similarly, the "+p is not pasting the clipboard contents from system clipboard..

System Info:

pi@readonly:~/new$ vi --version | grep IMproved
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Sep 30 2017 18:21:38)
pi@readonly:~/new$ vim --version | grep clipboard
+clipboard       +job             +path_extra      +user_commands
+eval            +mouse_dec       +statusline      +xterm_clipboard
pi@readonly:~/new$    

When I open any file in VIM, and try to check for the register +, I am getting this:

:reg +
--- Registers ---
Press ENTER or type command to continue   

Also, when I run :echo has('clipboard'), I am getting 1

@PatrickBacon, I have yanked the highlighted text by clicking on v, scrolling through the text and using "+y. Here are the registers showing:

:reg
--- Registers ---
""       int c;^J    for (i = 0; i < sizeof(s) - 1 && (c = getchar()) != EOF;) {^J       s[i++] = c;^J       if (c == '\n
"0       int c;^J    for (i = 0; i < sizeof(s) - 1 && (c = getchar()) != EOF;) {^J       s[i++] = c;^J       if (c == '\n
"1   ^J
"2   ^J
"3   p^J
"4   ^J
"5   ^J
"6   p^J
"7   p^J
"8       char s[64];^J    size_t i;^J
"9   int atoi(const char *s) {^J    int n = 0;^J    size_t i = 0;^J^J    while (s[i] == '0')^J        i++;^J    if (s[i]
"r         while (s[i] >= '0' && s[i] <= '9')^J            n = 10 * n + (s[i++] - '0');^J
"u       size_t i = 0;^J^J    while (s[i] == '0')^J        i++;^J    if (s[i] >= '1' && s[i] <= '9') {^J        n = s[i++
"z   t main() {^J    char s[64];^J    size_t i;^J    int c;^J
"-   i
"%   t.c
Press ENTER or type command to continue 

Hence, it looks like the yanking is working within vim..

Questions:

1) What else I should check to verify, that all the requirements for "Copying highlighted in VIM text into the remote system clipboard" have been met?

2) Do the registers that exist within VIM, are the real files in some directories in my Linux, buffered?

3) How does the remote system clipboard looks like to the Linux system, to which I am connecting via SSH? In other words, does the remote system clipboard is simply the STDOUT file or part of it, on the Linux?

1
2) Do the registers that exist within VIM, are the real files Nop, they are memory buffers.phd
If you are using linux you have to use vim-gtk to be able to copy to clipboard, it's all explained here (stackoverflow.com/questions/3961859/…)Santi
3) How does the remote system clipboard looks like to the Linux system, to which I am connecting via SSH? There is no such thing as a system clipboard in Unix/Linux. There are clipboards and copy buffers in X Windows.phd
@phd What do you mean by 'memory buffers'? In other words, do you mean, the VIM itself consume some RAM on the runtime and the files are stored within it, or expanding...?readonly
Yep, exactly so.phd

1 Answers

0
votes

In general, you can't copy text from a remote system program to the current system natively over SSH. The exception is when you run an X11 server on your local machine and the remote system runs an X11-compatible client, and you have X forwarding enabled for the SSH connection. Since you're using Windows, I doubt that you're running an X11 server on your local system.

Clipboards are a feature of whatever window system you're using, and Windows and X11 (the typical Linux window system) don't share a compatible interface. The X11 clipboards (there are multiple) are stored in memory in the program until the X server speaks to the program with the clipboard data and asks for the data in a particular clipboard. This data isn't just standard output; it's a dedicated block of memory and a particular protocol.

If you want to be able to copy blocks of text from a remote terminal, the easiest way is to use something like tmux on your local system, and then connect to the remote system through tmux. You can configure tmux to copy and paste data from the terminal into your clipboard using shortcut keys. This will result in a configuration that works for all terminal programs and connections run within tmux, not just Vim.

For example, you could use a key binding like the following (bound to y) to automatically copy and paste to the Windows clipboard:

bind-key -T copy-mode-vi y send -X copy-pipe 'clip'