Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scroll vim window in Tmux copy mode?

Tags:

vim

tmux

Using tmux in copy mode, I cannot get the vim window to scroll. Is this possible? I'm trying to copy a huge chunk of text in vim inside of one tmux window and paste into another. Thanks.

like image 937
Corey Rothwell Avatar asked Sep 13 '26 16:09

Corey Rothwell


2 Answers

I know what you ask for and I searched the net to find it as well. It is something that have bothered me as well. This however might help you with your problem:

http://www.vim.org/scripts/script.php?script_id=4488 - a vim plugin. Not as fancy solution as to enter copy mode and scroll within vim instead of the history/scrollback buffer of tmux.

like image 79
Aquaplanet Avatar answered Sep 18 '26 11:09

Aquaplanet


try if this works for your needs:

function! SetTmuxBuffer() range
    execute "!tmux set-buffer '" .join(getline(a:firstline, a:lastline),"\015")."'"
endfunction

command! -range ToTmux <line1>, <line2> call SetTmuxBuffer()

put above codes in your vimrc or in a vim file and source it. then you can for example send line1-line8 to tmux buffer:

:1,8ToTmux

or visual select, then

:'<,'>ToTmux

go to another tmux window, try pasting the lines in vim.

like image 27
Kent Avatar answered Sep 18 '26 12:09

Kent