3

Vi has named buffers by typing "[a-z], followed by your yank/delete/etc command. Does tmux's vi copy-mode have named buffers? I'd like to copy various strings into different tmux buffers and be able to paste them individually

1 Answer 1

1

Yes, it does.

man tmux /^BUFFERS or the web copy:

tmux maintains a set of named paste buffers. Each buffer may be either explicitly or automatically named. Explicitly named buffers are named when created with the set-buffer or load-buffer commands, or by renam‐ ing an automatically named buffer with set-buffer -n. Automatically named buffers are given a name such as ‘buffer0001’, ‘buffer0002’ and so on. When the buffer-limit option is reached, the oldest automati‐ cally named buffer is deleted. Explicitly named buffers are not sub‐ ject to buffer-limit and may be deleted with delete-buffer command.

Buffers may be added using copy-mode or the set-buffer and load-buffer commands, and pasted into a window using the paste-buffer command. If a buffer command is used and no buffer is specified, the most recently added automatically named buffer is assumed.

...

The buffer commands are as follows:

...

load-buffer [-b buffer-name] path
               (alias: loadb)
         Load the contents of the specified paste buffer from path.

paste-buffer [-dpr] [-b buffer-name] [-s separator] [-t target-pane]
               (alias: pasteb)
         Insert the contents of a paste buffer into the specified pane.
         If not specified, paste into the current one.  With -d, also
         delete the paste buffer.  When output, any linefeed (LF) char‐
         acters in the paste buffer are replaced with a separator, by
         default carriage return (CR).  A custom separator may be speci‐
         fied using the -s flag.  The -r flag means to do no replacement
         (equivalent to a separator of LF).  If -p is specified, paste
         bracket control codes are inserted around the buffer if the
         application has requested bracketed paste mode.

I truncated some of the information (including other buffer commands); definitely take a look at the website above (or the man page) for how to use these tools.

1
  • 2
    There are other things you can do with named buffers; for example, you can make choose-buffer show only a subset of buffers. Say you create a bunch of preset buffers with your favourite text and a common name prefix like mybuffer0, mybuffer1 etc, you can bind a key to for example choose-buffer -f '#{m:mybuffer*,#{buffer_name}}' to select from only those buffers. Or just bind keys to paste them directly pasteb -bmybuffer0. Commented Jan 29, 2020 at 8:35

Not the answer you're looking for? Browse other questions tagged or ask your own question.