Wednesday, May 8, 2024
 Popular · Latest · Hot · Upcoming
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 4031  / 2 Years ago, wed, september 21, 2022, 4:08:06

What is the command to copy all the contents to the system clipboard from a file open in an instance of the vi editor on a remote server, accessed via SSH. Also, what is the shortcut for pasting from system clipboard to vi.


More From » 12.04

 Answers
6

UPDATE: it became clear that vipin8169 runs vim on a remote server -- naturally, the vim over there does not have access to the clipboard of the local workstation, so the answer below is not applicable.



:set clipboard=unnamed


Everything you yank from now on will be copied to the clipboard, so to copy the whole file, do 1GvGGy in the normal mode. After that, you can use Ctrl-V or middle button click in any other application to paste the contents of the file.



Explanation: 1G means go to the beginning of the file (2G would be "go to the beginning of the second line"). v is to start marking a block. GG goes to the end of the file, y yanks it into the unnamed register (which is now also clipboard thanks to :set clipboard=unnamed).



Also, whenever you copy something from now on, you will be able to paste it with the regular p keypress.


[#35580] Thursday, September 22, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
zebrla

Total Points: 356
Total Questions: 110
Total Answers: 120

Location: Sudan
Member since Tue, Aug 3, 2021
3 Years ago
;