Edit tmux output with Vim (or any text editor)

acro5piano profile image Kay Gosho Updated on ・1 min read


We can scroll tmux output with C-b [ by default, and it provides vim like key binding.

However, some bindings are different from my customized vim.

So I add some scripts and settings to open tmux output with Vim (or any other text editor).

Fortunately, tmux has a nice command capture-pane!


# $HOME/bin/vim-edit-tmux-output

tmux capture-pane -pS -32768 > $file
tmux new-window -n:mywindow "vim '+ normal G $' $file"

chmod +x $HOME/bin/vim-edit-tmux-output

# $HOME/.tmux.conf

setenv -g PATH "$HOME/bin:$PATH"
set-option -g history-limit 20000

bind-key C-e run-shell "vim-edit-tmux-output"

Then press C-b C-e and you can open your tmux output!

Another nice feature is that tmux automatically closes the new pane for Vim after quiting vim.

Posted on by:


markdown guide

Neat, thanks for sharing! I found you can also do -S - to get the entire scrollback buffer (regardless of size) in case that's what the objective of the large -32768 number is.


I also found I have to add the following option to .tmux.conf to see the entire scroll buffer:

set-option -g history-limit 20000

And I added '+ normal G $' to vim launching option to open the file at the bottom:

tmux new-window -n:mywindow "vim '+ normal G $' $file"

That's pretty neat. Sometimes I do C-b [ then <space> move around to select text with arrows then <enter> to copy it to your clipboard


Yes, tmux has the ability by default.
Sometimes I want to edit, join, and search the text before copy ;)