0

I'm using https://github.com/vim-scripts/Smart-Tabs/blob/master/plugin/ctab.vim through Vundle. How can I temporarily disable it (preferably more readily than by commenting out the bundle and restarting the editor)?

3
  • try enabling paste mode :set paste Aug 12, 2017 at 20:21
  • There is a duplicate on SE with an answer.
    – statox
    Aug 14, 2017 at 11:26
  • 1
    The answer on SE asks the user to disable the plugin by modifying the .vimrc file.. while OP mentions otherwise..
    – alpha_989
    Aug 14, 2017 at 16:32

1 Answer 1

1

This plugin does not offer a method of temporarily disabling it. Therefore you have four options I can think of:

  1. The main functionality of the plugin is provided by insert mode mappings for the Tab and Backspace keys. You can remove these mappings with :iunmap <tab> | iunmap <bs> and renable by reloading the plugin entirely with :source [...]/ctab.vim. (You'll need to fill in the ellipsis with the correct path, I don't know offhand to what location Vundle downloads files.)

    This should work because this particular plugin doesn't seem to follow the standard practice of checking a guard variable to prevent itself from being loaded multiple times. If it did, you'd first need to reset the guard variable before reloading.

  2. Fork the plugin and edit it to add this feature. The two most obvious ways of doing this are to:

    1. Edit the InsertSmartTab() and DoSmartDelete() functions to immediately return if a new global variable g:ctab_temporarily_disable is set.

    2. Add a SmartTabDisable() function to call iunmap, and wrap the lines that create the mappings in a function (so it can be invoked from outside the plugin) to re-enable.

  3. As suggested by Christian Brabandt in a comment, you can disable all insert maps with :set paste and then re-enable with :set nopaste.

    This has a number of other effects, so it's more of a workaround than a solution, but if it meets your requirements it's the simplest option.

  4. (You've already stated you don't want to do this) Comment out the Vundle line and run :PluginClean, (or otherwise disable the plugin,) and restart the editor.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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