https://stackoverflow.com/questions/18258561/pasting-a-huge-amount-of-text-into-vim-is-slow/79633075

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!

all 6 comments

sorted by: hot top controversial new old
[–] 6 points 1 year ago* (2 children)

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.

  • source
  • hideshow 4 child comments
  • [–] 5 points 1 year ago (1 child)

    What is the benefit of involving cat?

  • source
  • parent
  • hideshow 2 child comments
  • [–] 1 point 1 year ago (1 child)

    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.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 4 points 1 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.

  • source
  • parent
  • [–] 3 points 1 year ago

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

  • source