Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emulate pastetoggle in neovim

Tags:

paste

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.

like image 591
January Avatar asked Sep 16 '25 14:09

January


1 Answers

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)

like image 113
paperlib Avatar answered Sep 18 '25 10:09

paperlib