Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using vim on Linux. I have xml.vim plugin loaded. If I do a paste of a string like "\." what I get is ">". If I do an insert, and pause, I can type "\." Apparently this is due to insert mode mapping". I edit xml, and like the plugin - has anyone addressed this problem?

share|improve this question
I got some background from… but it provides no presecriptive solution. – cvsdave Apr 9 '13 at 13:28
up vote 1 down vote accepted

Vim's paste mode disables features that can interfere with pasting, such as mappings and indentation. Simply :set paste before pasting and :set nopaste when you're done.

Because paste disables mappings in Insert mode, you can't use regular mappings to toggle it, but you can use the pastetoggle option instead. For example, to define F9 as a toggle key:

:set pastetoggle=<F9>
share|improve this answer
Thanks Bradd! Solves my problem. I used :set pt=<f9> as recommended by… as a working fix. – cvsdave Apr 11 '13 at 13:55
Thanks for posting the link: pastetoggle is easier to use than I thought. The extra example in the Vim docs confused me. I'll update my answer with the simple usage. – Bradd Szonye Apr 11 '13 at 20:30

It doesn't?! When you have :imaps starting with \, and you have identified them, either avoid their definition (if the plugin allows to configure a different mapping or to turn off mappings), or :iunmap the offending mapping. When the problem only occurs for the xml filetype, the place for that would be ~/.vim/after/ftplugin/xml.vim.

share|improve this answer
Thank you for your response. I don't quite have the time to explore the situation right now, and so am choosing the 'pastetoggle' solution suggested above. – cvsdave Apr 11 '13 at 13:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .