Score:0

Mobaxterm vs vim text copy

mx flag

Can I somehow copy text between two vim sessions in 2 different terminals? I use mobaxterm and can not scroll while marking text that I want to copy.

How can I do it? Edit 2 files on 2 different terminals (SSH sessions) with multiexec option and copy more text than I can see on terminal. I can not highlight it in any vim mode to copy it to my laptop notepad or other terminal SSH session window.

in flag
When copying more than screenheight, I usually use `cat` and select the content there...
Kamil Bu avatar
mx flag
This is, in fact, kind of solution :) but maybe someone can let us know if there is any better way to do it, i tried also other vim modes but i could not select text:)
Score:0
cn flag

In vim, you can use the r command to read a file or command from somewhere else. So, what I would do in this scenario is:

  1. Dump what you want to copy to a file, either by redirecting the output of a command, or it's already a file so just save it.
  2. Open vim in the other terminal and go to the file you want to paste into
  3. Use :tabe from command mode to open a new tab
  4. Use :r /path/to/file to read the content of that file that you created in (1) into the buffer
  5. Then use yank/paste as normal, or use ctrl-V in command mode to do a visual select block and yank that.

Note you can pass a command to :r as well, but you have to escape some characters, so :r! date +\%s will get the current unix time and insert it into the file.

Lots more tips on the well known Grok Vim post.

You can also do things like turn on line numbering with :set number, and then read specific lines from a file: :r! sed -n 147,227p /path/to/foo/foo.c

Or, use the line numbering with relative numbering (:set relativenumber) to show you easily how many lines to yank with y. That way you just do 37y and then p where you want it.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.