Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to copy and paste between different tmux panes running vim instances

Tags:

vim

vi

tmux

Example: copy in one tmux pane (via vim), then switch to another pane (running another vim instance) and paste using the vim paste command. I know this can be done via tmux (using prefix+]) but it would be really handy if I can copy and paste using vim bindings since i'm just switching between different panes running vim.

Any ideas?

like image 630
gylaz Avatar asked Jun 14 '12 23:06

gylaz


People also ask

How do you highlight in tmux?

Assuming your tmux command shortcut is the default: Ctrl + b , then: Ctrl + b , [ Enter copy(?) mode. Move to start/end of text to highlight.


2 Answers

Sorry, I'm trying to convince you to use vim built-in features.


To make the copy/paste easy, you can open files in another Tabpages:

:tabe /path/to/another/file 

Use gt or gT to switch Tabpages.


Or split the window to edit another file:

:sp /path/to/another/file 

Use Ctrl-ww to switch Windows.
To split the window vertically, please use :vsp file


Update:

This is my .tmux.conf file:

# vim setw -g mode-keys vi bind [ copy-mode bind -t vi-copy v begin-selection bind -t vi-copy y copy-selection bind -t vi-copy V rectangle-toggle bind ] paste-buffer  # buffer bind Space choose-buffer 

I only use them when I need to copy terminal output.

like image 123
kev Avatar answered Oct 11 '22 23:10

kev


I've been used this handy binding for several years :)

" copy to buffer vmap <C-c> :w! ~/.vimbuffer<CR> nmap <C-c> :.w! ~/.vimbuffer<CR> " paste from buffer map <C-p> :r ~/.vimbuffer<CR> 
like image 40
chenkaie Avatar answered Oct 11 '22 23:10

chenkaie