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.
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.
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.
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.This question cannot be answered in a simple way, but here you will find a very good tutorial.