8

When I try to copy and paste between tmux sessions or windows, one problem is that I usually have line numbers displayed when using Vim and tmux copies the line numbers:enter image description here

Is there any way to avoid this?

2
  • set nonu, or "+y... Commented Dec 20, 2017 at 23:39
  • or with more complication see what vim-tmux-navigator does; there may be a way to have tmux save-bufer - | somethingthatstripsthenumbers set when in vim under tmux (though that may require routing through the os clipboard, or a corresponding tmux set-buffer ...) Commented Dec 21, 2017 at 0:20

2 Answers 2

2

tmux has the rectangle-toggle command for this. It's not fully explained in the man page; it only appears in the list of commands available during copy mode:

Command vi emacs [...] rectangle-toggle v R 

It switches between the line-based selection you demonstrate, and rectangular selection (similar to Vim's blockwise visual mode). In the latter mode, you can start your selection at static and extend down+right without taking in anything to the left (the line numbers).

2
  • I can only seem to make this work with Emacs mod. When I do C-b then :set-window-option -g mode-keys vi then try the C-b [ then v to C-space, it doesn't seem to work. Commented Nov 25, 2020 at 16:40
  • @FilBot3 It works for me (tmux 3.1c). In vi mode the begin-selection binding is space rather than C-space, does that help? Commented Nov 26, 2020 at 19:14
2

Press Ctrl v and then v, it works like vim block mode.

Demo: https://gitea.balki.me/balki/casts/src/branch/main/tmux_block_select.cast

❯ tmux -V tmux 3.2a 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.