简体   繁体   中英

How to copy every line to clipboard in Vim for read-only file?

I found that gg"*yG copies every line to clipboard, and it worked. However, for read-only file, the command does not work. To be more precise, the original file has 89 lines, but gg"*yG copies 50 +- 1 lines only.

How solve this problem?

Note. I cannot change the file because it is in the server and I have not the authority.

A simpler command would be :%y* , where:

  • % is a shorthand for the range 1,$ , which means "from line 1 to last line",
  • y is the command :y , "yank",
  • and * is the target register.

But this is ultimately unrelated to your problem, which is that, by default, Vim only saves the 50 first lines of registers. That limit is set with the viminfo option, which has the following default value:

100,<50,s10,h

This is what :help 'viminfo' has to say on the matter:

<   Maximum number of lines saved for each register.  If zero then
    registers are not saved.  When not included, all lines are
    saved.  '"' is the old name for this item.
    Also see the 's' item below: limit specified in Kbyte.

To change the limit from 50 to 100 manually, say before yanking, do:

:set viminfo-=<50 viminfo+=<100

To change it permanently, add the line above to your vimrc .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM