Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 superuser.com/questions/354545/… but it provides no presecriptive solution. –  cvsdave Apr 9 '13 at 13:28

2 Answers 2

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 commandlinefu.com/commands/view/6122/… 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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.