Copy all the lines to clipboard

前端 未结 25 2227
礼貌的吻别
礼貌的吻别 2020-11-28 16:54

Is there any way to copy all lines from open file to clipboard in VI editor. I tried yG but it\'s not using clipboard to store those lines.

So

相关标签:
25条回答
  • 2020-11-28 17:35

    you can press gg to locate your curser to the start of the file,then press yG to copy all the content from the start to end(G located) to buffer.good luck!

    0 讨论(0)
  • 2020-11-28 17:37

    :%y a Yanks all the content into vim's buffer, Pressing p in command mode will paste the yanked content after the line that your cursor is currently standing at.

    0 讨论(0)
  • 2020-11-28 17:37

    I couldn't copy files using the answers above but I have putty and I found a workaround on Quora.

    1. Change settings of your PuTTY session, go to logging and change it to "printable characters". Set the log file
    2. Do a cat of the respective file
    3. Go to the file you set in step #1 and you will have your content in the log file.

    Note: it copies all the printed characters of that session to the log file, so it will get big eventually. In that case, delete the log file and cat the target file so you get that particular file's content copied on your machine.

    0 讨论(0)
  • 2020-11-28 17:38

    You should yank the text to the * or + registers:

    gg"*yG

    Explanation:

    • gg to get the cursor to the first character of the file
    • "*y to start a yank command to the register * from the first line, until...
    • G to go the end of the file
    0 讨论(0)
  • 2020-11-28 17:39

    on Mac

    • copy selected part: visually select text(type v or V in normal mode) and type :w !pbcopy

    • copy the whole file :%w !pbcopy

    • past from the clipboard :r !pbpaste

    0 讨论(0)
  • 2020-11-28 17:40

    If you're using Vim in visual mode, the standard cut and paste keys also apply, at least with Windows.

    • CTRLA means "Mark the entire file.
    • CTRLC means "Copy the selection.
    • ESC means "De-select, so your next key press doesn't replace the entire file :-)

    Under Ubuntu terminal (Gnome) at least, the standard copy also works (CTRLSHIFTC, although there doesn't appear to be a standard keyboard shortcut for select all (other than ALTE followed by A).

    0 讨论(0)
提交回复
热议问题