3

I am trying to use Tmux and Vim for better efficiency. Unfortunately, there is a copy/paste issue, as it is not possible to use the Vim visual mode between two panes of Tmux.

Several methods have been discussed in this 9-years-old post, but they are tedious: How to paste text from Vim editor to browser?

I was wondering if a consensus has been reached nowadays on the best method to use?

  • 2
    Asking for the best method will result in opinion-based answers. If you need a solution for a problem you can of course ask for a solution and then choose the best answer from your point of view. Does any answer to the referenced question solve your problem? If yes, then we don't know which would be the best method for you. If not, then please [edit] your question and add more details about your problem why "it is not possible to use the Vim visual mode between two panes of Tmux" and why the existing answers don't fit in your case. – Bodo Aug 17 '21 at 16:56
  • There is the vim-slime plugin which allows you to 'send' selected text from vim directly to a tmux (or screen) pane: https://github.com/jpalardy/vim-slime – mattb Aug 17 '21 at 17:00

1 Answers1

3

I'm assuming that you want to copy-paste between 2 vim processes running in 2 different tmux panes.
You can do this by adding the following to your ~/.vimrc:

" Enable copying from vim to the system-clipboard
set clipboard=unnamedplus  

Now you copy in 1 vim process, navigate to your other vim process using tmux, and paste.

This also works if vim is running in another tmux window. Or if you want to paste from vim to another process (e.g. your browser).

For more information you can run: :help 'clipboard' inside vim.

melvio
  • 288
  • Thank you melvio, it works pretty well from one VIM pane to another! However, it seems that it doesn't work out of VIM. It is not possible to paste the text to a terminal or a browser.

    Do you have a specific method to do it?

    – Drosera_capensis Aug 17 '21 at 18:54
  • 1
    My apologizes, the content yanked can be pasted with a simple Ctrl+V. Thanks a lot melvio! – Drosera_capensis Aug 17 '21 at 19:01
  • This not gonna work on virtual machine without desktop environment accessed by ssh – Dmitry Aug 01 '22 at 10:50