Score:0

How to enable clipboard support on Ubuntu server?

fk flag

I have VIM installed with clipboard and xterm_clipboard supported. But registers "* and "+ don't work. I suspect that Ubuntu server version doesn't have GUI support, so it doesn't have clipboard support neither. According to VIM documents, "* stands for PRIMARY selections and "+ stands for CLIPBOARD in X server. I access to the server through SSH. What I want to do is to copy/paste between separate VIMs opened in different terminals. The case likes I open two terminal accesses to ubuntu server through SSH and open VIM in these two terminals. If PRIMARY selection and CLIPBOARD are supported, VIM can access them when do copy/paste so that I can copy/paste between two VIMs quickly.

I can copy/paste through mouse selection from windows terminal. But this relies on windows terminal's feature. If I can copy/paste directly in VIM through ubuntu server's clipboard, that would be much convenient.

Thanks for @muru's clarification. Now, I understand more clearly X11 and X11-forwarding. What I ask is how to enable X11 on ubuntu server so that VIM can use X11's clipboard and the copy/paste content can be shared in different Vim sessions. Ideally, I don't want to install whole GUI packages. I tried to install xorg and xauth, but they don't work.

Unable to copy text from the terminal to external programs is not what I want. It solves copy/paste between terminal and other programs on local PC. But what I want is to copy/paste between different Vim sessions opened on same server.

Finally, I found the answer https://vi.stackexchange.com/questions/19899/vi-and-registers-do-not-exist. It works for me.

muru avatar
us flag
How are you accessing the server? SSH? TTY? What are you pasting to?
cpcopy avatar
fk flag
I access to the server through SSH.
muru avatar
us flag
Does this answer your question? [Unable to copy text from the terminal to external programs](https://askubuntu.com/questions/608233/unable-to-copy-text-from-the-terminal-to-external-programs)
cpcopy avatar
fk flag
Thanks for the infor. It looks like this question wants to solve the copy/paste between local and remote server.
muru avatar
us flag
Then what are you pasting to?
cpcopy avatar
fk flag
Just updated the question. I want to copy/paste between two separate VIMs opened in two terminals. Both VIMs opened in same ubuntu server. So, I want to use the ubuntu server's clipboard to exchange the data between two VIMs.
muru avatar
us flag
There is no such clipboard. Vim' external clipboard support is using the X11 one, and over SSH, that's X11-forwarding. But you don't really need that for the use case you're talking about. Just write the contents you want to copy to some file and read that file from the other Vim session.
cpcopy avatar
fk flag
Thanks. I understand. I found the solution using a temp file. I thought VIM already have the system clipboard support. It would be better to use that way. Let me try the X11-forwarding way.
muru avatar
us flag
"I thought VIM already have the system clipboard support", it does, but without X11, there is no system clipboard.
cpcopy avatar
fk flag
OK. So, over SSH, VIM can only use X11-forwarding. Even I add X11 support on ubuntu server and disable X11-forwarding over SSH, it still cannot use the system clipboard, right?
muru avatar
us flag
No, I said Vim can only use X11's clipboard. If you have X11 running on the server, then point Vim to it using the `DISPLAY` variable, and Vim will be able to use it. (X11 forwarding sets `DISPLAY` to you local system's X11, and then Vim is able to use that.)
cpcopy avatar
fk flag
Thanks for the clarification. Using X11's clipboard on the server is what I want to do. But I don't see $DISPLAY variable on the server. So, I think I don't have X11 running on the server. I want to setup X11 on server, then Vim can use the X11's clipboard on server.
cpcopy avatar
fk flag
Finally, I found the answer https://vi.stackexchange.com/questions/19899/vi-and-registers-do-not-exist. It works for me.
Score:0
vn flag

It's not entirely clear from your question what you want to do, but as an alternative to X.org clipboard, you can use tmux, which has a copy mode and multiple buffers that can be used to copy and paste text.

For the default keybindings in tmux:

  • Ctrl+b then [: Enter copy mode
  • Space: Start selection
  • Esc: Stop selection
  • Enter: Copy selection to buffer
  • Ctrl+b then ]: Paste contents of top buffer (when no longer in copy mode)

Reference here: Tmux cheatsheet.

cpcopy avatar
fk flag
Thanks for the answer. I use terminal and SSH to access the server. I have updated my question.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.