PSA: How to paste large amounts of text in Vim

a year ago by paequ2 to c/vim

https://stackoverflow.com/...

I recently ran into this. I didn't realize that the swpfile slowed down pastes.

I was trying to paste 50kb of text in Vim, but it kept getting stuck and I had to kill -9 it.

But, then I ran :set noswapfile and the paste was instant! TIL!

Penguincoder 6 points a year ago

Save it in a text file in the same directory. Then open the file you want put it in with vim. Move the cursor to the spot in the file you want to paste the text. Hit Esc then : and type r!cat (the file name you saved and want to paste the data from) , press enter.

This will read in the other file and put the contents into the one you have open in vim.

path: 0 17196691, hotness: undefined, score: 6, children: 4
zygo_histo_morpheus 6 points a year ago

you can just do :r path/to/file directly

path: 0 17196691 17197830, hotness: undefined, score: 6, children: 0
korthrun 5 points a year ago

What is the benefit of involving cat?

path: 0 17196691 17197410, hotness: undefined, score: 5, children: 2
Penguincoder 1 point a year ago

Just a habit, because you can run any command and get the stdout into vim in that method. Like for getting your shebang or an ls listing.

path: 0 17196691 17197410 17209384, hotness: undefined, score: 1, children: 1
korthrun 4 points a year ago

Then for the casual reader: don't pick this habit up. There's no reason to fork/exec a shell, invoke cat for the purpose of printing to stdout, then move the data into your buffer. You can just do :r somefile.txt.

path: 0 17196691 17197410 17209384 17209683, hotness: undefined, score: 4, children: 0
kionite231 3 points a year ago

Thank you so much for sharing it, I didn't know either!

path: 0 17196448, hotness: undefined, score: 3, children: 0
vim
vim

@lemmy.sdf.org

login for more options
1239
41
8

For Vim enthusiasts and anyone interested in Vim/Neovim!

"VIM is the greatest editor since the stone chisel." - Dr. Jose Unpingco

#HJKL

go to feed...