I'm assuming that by "terminal buffers" you mean the :terminal
command. In theory you can just use the ++cols=1000
option or :set termsize
(8.0)/set termwinsize
(8.1) commands to set a wider terminal width, at the expense of having to scroll to read the whole line. In practice, this new feature seems rather buggy.
There are other options, however.
Copying Using the Terminal Program's Cut and Paste
TLDR: Avoid "visual" (curses-using) programs such as Vim or less when copying from a terminal; instead just cat
or type
the file in a terminal and use the terminal program's copy function.
The most common way of handling this is to use the terminal's ability to do cut and paste to the windowing system's clipboard. Select the text in one window using your mouse, choose "Copy" from the terminal application's menu or via hotkey, move the focus to the other window, put vim into insert mode, and choose "Paste" from that terminal application's menu or via a hotkey. Vim will see this text as being "typed in" from the keyboard; the terminal application is what's "typing" the characters.
When you do that sort of copy above, it's best to use a non-visual mode program to display the text. If you cat
or type
a file with lines that wrap, the terminal will see this as a long string of characters with a newline, and the terminal, though it will wrap the text (if configured to do so), will know that there is no LF, CR or similar between the last character on one row and the first character on the subsequent row; this will be reflected on what gets copied. On the other hand, programs like vim may not send the text to the terminal that way since they're concerned primarily with a nice visual display and it's safer to send a CR or cursor movement command when printing on a new line than to rely on the terminal's automatic wrapping; the terminal may see this as a newline when copying.
In particular, :terminal
in Vim itself is doing exactly this kind of wrapping (turning a single output line into multiple lines as it wraps), which appears to be the problem you're experiencing.
Command-line Vim and the Windowing System's Clipboard
Another option is to use vim's interface to the windowing system's clipboard. This has several requirements:
- Your windowing system is X11 (Linux, *BSD, X11 server running under Windows, etc.).
- Any remote machine you're using has a connection to that X11 server (e.g., via
ssh -X
. (Local terminals need access to, but this is typically automatic via the DISPLAY
environment variable.)
- You're using a version of
vim
with support for X11 communications (vim --version
shows +X11
, not -X11
).
In these cases you can use vim on both sides, yanking into the "+
or "*
buffer in one vim and pasting from that buffer in the other vim.
Actually, the command-line version of Vim for windows can have these capabilities too when run locally. The version I have, built for MSYS and run from bash
in a mintty
terminal, works well for this. I believe that this was installed along with various other Unix-y tools when I installed Git for Windows, but I'm sure that there are various sources for various builds of Vim to run under both MSYS or at regular Windows command lines.