1

I guess my question may be similar to vim system register * and + not working but my server version is ubuntu. And I'm sure the installed vim has clipboard support. However, I cannot see the "+ register when I run :reg in vim. The followings are the commands I use to diagnose such condition but I still cannot find the solution.

First, I use ssh to connect to this server. To check the availability of clipboard support of Vim:

$ vim --version | grep clipboard
+clipboard       +insert_expand   +path_extra      +user_commands
+emacs_tags      +mouseshape      +startuptime     +xterm_clipboard

However, when I run :reg in one file opened by vim, I cannot see the system clipboard register. Here is what I got, (I removed the contents of these registers)

:reg
--- Registers ---
""
"0 
"1
"2
"3
"4 
"5 
"6
"7
"8
"9
"q 
"-
": 
"%   /usr/share/vim/vim74/doc/change.txt
"#   new.txt
"/   help registers

The os of this server is Ubuntu 16.04.4 LTS if this information can be helpful.

Also, I guess I have installed the dependencies of vim with clipboard, here is a subset of what I get when I run apt list --installed:

vim-common/xenial-updates,xenial-security,now 2:7.4.1689-3ubuntu1.2 amd64 [installed] vim-gnome/xenial-updates,xenial-security,now 2:7.4.1689-3ubuntu1.2 amd64 [installed] vim-gtk/xenial-updates,xenial-security,now 2:7.4.1689-3ubuntu1.2 amd64 [installed] vim-gui-common/xenial-updates,xenial-updates,xenial-security,xenial-security,now 2:7.4.1689-3ubuntu1.2 all [installed,automatic] vim-runtime/xenial-updates,xenial-updates,xenial-security,xenial-security,now 2:7.4.1689-3ubuntu1.2 all [installed,automatic] vim-tiny/xenial-updates,xenial-security,now 2:7.4.1689-3ubuntu1.2 amd64 [installed] vino/xenial-updates,now 3.8.1-0ubuntu9.2 amd64 [installed]

Haoran Shi
  • 68
  • 8
  • https://askubuntu.com/questions/347519/unable-to-copy-from-vim-to-system-clipboard – phd May 29 '18 at 06:17
  • Do you have a working X on that server? – romainl May 29 '18 at 07:33
  • @romainl I'm not sure. Could you be so kind to give more information to check that? – Haoran Shi May 29 '18 at 08:47
  • @phd I tried to `set clipboard=unnamedplus`, and run `set clipboard?` in vim to double check. But I cannot see the `%+` register when I run `:reg` command. – Haoran Shi May 29 '18 at 08:50
  • The mail advice there is to install `vim-gtk`. I think the advice works because it installs GTK dependencies and they are what make `vim` works with X clipboard. – phd May 29 '18 at 13:13
  • @phd I have installed that already. And I have added this to the problem description. – Haoran Shi May 30 '18 at 08:48

1 Answers1

0

If you copy your text from your client, the text is being copied in the client-clipboard: "+@localhost.
So when using SSH, then starting Vim and type :reg, you can only see serverides registers, not client-side registers. "+@server is empty.

politinsa
  • 2,418
  • 6
  • 30
  • I'm not convinced that's the reason why the `"+` cannot be shown. Because it should be configured on the server already? Indeed, what I want to do is to copy text in vim with system clipboard on my server, so I could paste the content to another file on the server. I cannot use mouse selection to copy because it would cause many format errors ( like extra spaces, newlines and line numbers shown in vim). Or would you suggest me any other methods to copy and paste easily? Thanks! – Haoran Shi May 30 '18 at 08:55