I'm looking for a way to bind a key combination (something like leader+p) to toggle :set paste
on and off with the same key combo.
I know I can :set paste
and :set paste!
and can bind these to 2 different key combos but I'm looking to make a toggle.
Basically if you start in Insert mode and use Ctrl+Shift+V or right click paste with your mouse, Vim detects that this came from a terminal and automatically sets paste mode, then unsets it once done, so you don't lose remapped keys (which can't work in paste mode because its writing raw data) and you are back to a " ...
vimrc so pressing F2 toggles paste on and off.
In this mode, you can run Vim commands and navigate through the file. To go back to normal mode from any other mode, just press the Esc key. Vim has its own terminology for copying, cutting, and pasting. Copy is called yank ( y ), cut is called delete ( d ), and paste is called put ( p ).
If you have an US English keyboard, pressing Ctrl - [ is equivalent for pressing Esc . This provides an easy way to exit from insert mode. Alternatively use Ctrl - c .
There is a specific command to toggle paste mode :
set pastetoggle=<F10>
to set it to F10 key for example.
Edit : To use it with leader key, you would use
set pastetoggle=<leader>p
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With