I have a custom Vim configuration that I've been putting together. There's a number of cool plugins and features that aid in PHP development. However, when I open a large file (couple thousand lines) these features make vim crawl.

What I'm currently doing is renaming .vimrc to .vimrc- then relaunching vim when dealing with these large files so I have the default configuration. What I'd like to do is toggle between vimrc's without having to leave vim. Think that's possible? It's sorta like sourcing the .vimrc after changes but I need to source another file to override my default configuration.

  • 2
    You should review your config because two or three thousands lines is not large.
    – romainl
    Oct 22, 2014 at 19:35
  • It runs PHP Code Sniffer on save and I'm editing a sloppy file so nearly every line has some type of warning. That's what's slowing it down.
    – krimson
    Oct 24, 2014 at 14:39

3 Answers 3


Start vim with the --noplugin argument. You could possibly alias this. (You could also check e.g. for an environment variable in your .vimrc and if present set the loadplugins options). There are many ways, how one could script it. See also the faq here and here (Note the LargeFile plugin).

  • So how would you personally go about scripting it?
    – krimson
    Oct 24, 2014 at 14:40
  • I would probably go with a environment variable Oct 24, 2014 at 19:06

I guess you can always start vim with the -u option:

vim -u NONE

From man vim:

-u {vimrc} Use the commands in the file {vimrc} for initializations. All the other initializations are skipped. Use this to edit a special kind of files. It can also be used to skip all initializations by giving the name "NONE". See ":help initialization" within vim for more details.

  • Is there a way to do it within a single vimrc to avoid having to exit and go back into vim? Like a user function that would toggle which .vimrc was being used?
    – krimson
    Oct 22, 2014 at 18:42
  • This goes beyond my Vim expertise but I'm sure you can write your own function that disables "slow" plugins and invoke it whenever you want, bind it to a keystroke or even manage to automatically trigger it for certain file sizes/extensions. This answer is just a better alternative to renaming your .vimrc file every time.
    – cYrus
    Oct 22, 2014 at 19:09

The comments on your question reveal that your problem is a custom command that runs on every file save.

So a solution is to edit your custom command to check some variable. If that variable does not exist or has a "false" value, run your command. Otherwise, skip running the command. Then making the write happen quickly is as simple as setting that variable to true. You could do this in a command to make it easier. For example,

autocmd BufWritePost * if !exists('b:my_checker_skip_check') || !b:my_checker_skip_check | call DoMyCheck() | endif
command! MyCheckDisable  let b:my_checker_skip_check = 1
command! MyCheckEnable unlet b:my_checker_skip_check
  • Awesome. Now I just have to track down where the code to run that check is.
    – krimson
    Oct 31, 2014 at 16:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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