Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Temporarily disable vim plugin without relaunching

Tags:

vim

I'm using c-support in Vim. One of it's features is the automatic comment expansion.

When I'm pasting code into Vim from an external editor, the comments are expanded (which gives me double-comments and messes up the paste - see below for example). I'd like to be able to disable the plugin, paste, then re-enable it, without relaunching Vim. I'm not sure if this is possible.

The SO questions here, here and here all describe methods to disable plugins, but they all require me to close Vim, mess with my .vimrc or similar, and relaunch; if I have to close Vim, I might as well cat file1 >> myfile; vim myfile, then shift the lines internally, which will be just as quick.

Is it possible to disable a plugin while running vim without relaunching, preferably in a way which allows me to map a hot-key toggle-plugin (so re-sourcing ~/.vimrc is alright; that's mappable to a hotkey [I imagine, haven't tried it yet])?


Messed up comments:


/*
 *  *  Authors:
 *   *    A Name 
 *    *
 *     *  Copyright:
 *      *    A Name, 2012
 *       */

EDIT: It turns out you can :set paste, :set nopaste (which, to quote :help paste, will "avoid unexpected effects [while pasting]". (See the comments).
However, I'm still curious whether you can disable/enable a plugin as per the original question, so I shall leave the question open.

like image 267
simont Avatar asked Mar 29 '12 19:03

simont


Video Answer


1 Answers

Insert ":set paste" then paste your code. After that insert :set unpaste

like image 120
Florian Fackler Avatar answered Sep 21 '22 14:09

Florian Fackler