Pasting a huge amount of text into vim is slow?

前端 未结 4 902
梦毁少年i
梦毁少年i 2021-01-31 03:12

Someone showed me how to do this before but I can\'t figure out what it was now.

I know about :set paste but this is not the problem.

4条回答
  •  执笔经年
    2021-01-31 03:41

    This is a buffer flush-to-disk problem. Vim tries to keep your work safe and doesn't assume you can type several thousand characters per second. Read :help swap-file for some details on the buffering. The solution to your problem is this:

    Turn off vim's swapfile either with:

    vim -n 
    

    or from within vim before the paste:

    :set noswapfile
    

    See :help swapfile for more details.

    Another option is to simply turn off the syncing to disk of the swap file with :set swapsync= but this option takes more keystrokes to undo and I'm lazy. :)

    Turning off swap is not safe for normal operations! Immediately after the paste, either use :set swapfile or :set swapsync=fsync to revert back to normal behavior (though technically, normal behavior might have been sync and not fsync, check with :set swapsync? beforehand if you want to go this route).

提交回复
热议问题