Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vimrc addition to toggle :set paste

Tags:

vim

paste

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.

like image 370
darryn.ten Avatar asked Dec 20 '12 07:12

darryn.ten


People also ask

How do you use set paste?

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 " ...

How do I turn off paste mode in Vim?

vimrc so pressing F2 toggles paste on and off.

What is paste mode in Vim?

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 ).

How do I get out of insert paste mode?

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 .


1 Answers

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
like image 69
Xavier T. Avatar answered Oct 06 '22 21:10

Xavier T.