Home > other >  How to copy multiple pages from VI inside tmux session
How to copy multiple pages from VI inside tmux session

Time:11-11

I am trying to copy a long text around 350 lines. But i can select only 15-20 lines that are currently visible in terminal and i cannot scroll down once i select copy mode inside tmux. here are the steps

  1. tmux attach
  2. ssh user@host
  3. vi filename.java
  4. Ctrl b and [
  5. Ctrl space and then up/down left right arrow to make selection. After that once i reach to end 1 cannot scroll further to select rest of the text.

CodePudding user response:

Use cat command.

Example:

cat example.cfg

With the output of that command you can select with your mouse all the content you want instead of going every 30 lines to do it.

Then you can connect to your other server and just paste it into the new file.

CodePudding user response:

Assuming that you want to copy to the X clipboard...

make a long file.

$ ssh try 'seq 1 2000 >  /tmp/long-file'

edit it.

$ ssh -tY try vim /tmp/long-file

from inside vim, feed the file to the X clipboard.

$ :!xclip < %

On a different console:

$ xclip -o

If you disconnect before xclip -o the command will fail with:

Error: target STRING not available

This solution relies on X forwarding. If you can't do that than do this:

ssh try cat /tmp/long-file | xclip -i

If you're on mac OS, there is a similar paste command, I believe.

  • Related