pasteneovim

Emulate pastetoggle in neovim


The pastetoggle option has been removed from neovim and replaced by "Just Paste It(tm)". However, in my setup (ssh + screen) for some reason, the pasting does not work automatically and neovim attempts to autoformat the text I am pasting. Also, sometimes I would like neovim to autoformat the text that I am pasting.

How can I setup a manual switch between autoformatting and no autoformatting? The paste and nopaste settings still seem to work.


Solution

  • in vimscript ! toggles the state of an option
    so used that to toggle the state of the paste option:

    nnoremap <silent> <f5> :set paste!<cr>
    inoremap <silent> <f5> <esc>:set paste!<cr>i
    

    (as suggested by this comment to create a shortcut to toggle paste mode with Vim - dev community)