toggle PASTE in insert mode

26 views
Skip to first unread message

surge

unread,
Jul 26, 2015, 12:35:20 PM7/26/15
to vim_use
Hi everybody,

I'm trying to create a mapping in the insert mode that would toggle the PASTE option.

The mapping is defined like this:

inoremap - <ESC>:set map!<CR>i

The thing is, it works the first time and after that, when i type '-', a literal '-' is put in. According to :verbose onramp -, the mapping doesn't change.

Any ideas?

Thanks!!

Dmitri Vereshchagin

unread,
Jul 26, 2015, 12:56:12 PM7/26/15
to vim_use
* surge <ger...@gmail.com> [2015-07-26 19:35]:
> I'm trying to create a mapping in the insert mode that would toggle
> the PASTE option.

Check pastetoggle option.

--
Dmitri Vereshchagin

Sergei Gerasenko

unread,
Jul 26, 2015, 1:01:54 PM7/26/15
to vim...@googlegroups.com
I new about paste toggle and I thought i could only assign it to one key (like F5), but it appears that it works ever for something like <leader>]

So thanks!!

But still, why the behavior with inoremap?
> --
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to a topic in the Google Groups "vim_use" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/vim_use/Bh23dt9uiBM/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to vim_use+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Christian Brabandt

unread,
Jul 26, 2015, 1:12:34 PM7/26/15
to vim...@googlegroups.com
Hi Sergei!

On So, 26 Jul 2015, Sergei Gerasenko wrote:

> I new about paste toggle and I thought i could only assign it to one key (like F5), but it appears that it works ever for something like <leader>]

You can't toggle the paste option from a mapping, because the whole
point when paste is set is to disable any mappings.

That's why you have the pastetoggle option.

Best,
Christian
--
1. Der Computer nützt dem Menschen.
2. Die Erde ist eine Scheibe.
3. Computer lösen Probleme, die man ohne sie nicht hätte.
4. Nichts ist so einfach, daß man es nicht falsch machen könnte.

Dmitri Vereshchagin

unread,
Jul 26, 2015, 1:12:39 PM7/26/15
to vim...@googlegroups.com
* Sergei Gerasenko <ger...@gmail.com> [2015-07-26 20:01]:
> But still, why the behavior with inoremap?

Insert mode mappings and abbreviations are disabled if paste option is
on.

--
Dmitri Vereshchagin

Sergei Gerasenko

unread,
Jul 26, 2015, 1:15:01 PM7/26/15
to vim...@googlegroups.com
Aaaaaaaaaaah :)

Brilliant, thanks Dmitri!

Sergei Gerasenko

unread,
Jul 26, 2015, 1:16:18 PM7/26/15
to vim...@googlegroups.com
Got it. Makes sense. Thanks, Christian!
Reply all
Reply to author
Forward
0 new messages