vim limited line memory
im trying to copy 300 lines from one file to anoth开发者_运维技巧er, in source file i type "300yy", it says it has yanked 300 lines.
go to destination file and press p, it pastes, but only the first 50 lines.
any idea why it isn't pasting the 300?
To see the current settings during a vim session, run:
:set viminfo?
As suggested in Vim Tips Wiki, you can adjust the viminfo
setting (again, during a vim session) by running the ex-command:
:set viminfo='100,<1000,s100,h
or you can remove the :
and set it as default in your .vimrc
as:
set viminfo='100,<1000,s100,h
What the individual parts mean:
'100
Marks will be remembered for the last 100 edited files.<1000
Limits the number of lines saved for each register to 1000 lines; if a register contains more than 1000 lines, only the first 1000 lines are saved.s100
Registers with more than 100 KB of text are skipped.h
Disables search highlighting when Vim starts.
As Eugene and Zyx said adjusting your viminfo would be the easiest solution
:set viminfo-=<50,s10
An alternate solution would be use :read
and/or :write
To read in from file-name.txt into the current buffer
:read file-name.txt
To append the range of line 1 to line 300 from the current buffer to file-to-append.txt
:1,300write >> file-to-append.txt
You can also use marks instead of line numbers such as the visual marks
:'<,'>write >> file-to-append.txt
Of course appending may not be able to fulfill your use case in which the viminfo changes will probably work best.
:help :write
:help :read
:help 'viminfo'
:help :set-=
Stay in the same session (open the new file doing :e path) and you won't have any limitation.
try vim -p file1 file2
. It opens each file into a new tab (which is awesome), and it solves the copy/paste limit
Something that worked for me is, when in visual mode, copying with a command like :1,300y
that copies from line 1 to 300. You can switch this to any range of lines that you would like as :37,456y
to copy from line 37 to 456.
If your vim is not showing the lines, you can set the lines with the command :set numbers
If you want to use that yanked/copied lines in another file, i recommend opening multiples tabs and copying and pasting the info between them.
To do this you can open them in the terminal with the command vim -p file1 file2
.
To navigete between them you can use the commands gt
and gT
to move to the next and previous tab respectively.
精彩评论