I have a problem in Vim, and I think it may be in my vimrc file (or have been told it could be my vimrc file).How do I verify this? And if it is my vimrc file, how do I know what exactly it is?
How do I debug my vimrc file?
vimrc
The first thing you want to do is to start Vim with the default settings:vim -u NONE -U NONE -NThe -u NONE prevents Vim from loading your vimrc, -U NONE prevents Vim fromloading your gvimrc, and -N tells Vim to use no-compatible mode (this isn'trequired, but most Vim users are not used to compatible mode).Note that the NONE is required to be in all-caps.In Windows you can add these flags by creating a new shortcut1.If the problem stays, then you know it's not something in your vimrc.If the problem disappears, you now it's caused by something in your vimrcfile.It's not my vimrc!Hurray! Go and ask your question. Be sure to mention that you tried starting Vimwithout a vimrc file!So it's my vimrc, now what?If you haven't already, you probably want to save a backup copy of your vimrcfile first.Check the pluginsThe next thing you probably want to do is disable all plugins first; plugins canalter quite a bit in Vim. If this fixes the problem, then try to find outwhich plugin by re-enabling them one-by-one. After you've found out whichplugin exactly causes the problem, you can try & fix it by reading this plugin'sdocumentation, and/or by asking a question tagged with plugin-<name>.If it's not a plugin, and you don't have any idea what's causing yourproblem, then it's a trial-and-error procedure. Comment out one or more lines inyour vimrc, start Vim, check if the problem occurs, and repeat this procedureuntil the problem stops occurring. The fastest way of doing this is:Comment out (or remove) about half your vimrc file.Restart Vim, or open a new Vim (reloading the vimrc is not good enough, assettings aren't unset).Is the problem now gone? Put back the part you removed out (keeping Vimopen and using undo is useful here) and repeat step 1 on the part you addedback.Does the problem still occur? Go to step 1.In the end you should have a single option or a combination of a few optionsthat causes your problem. You can find out more about any option in Vim byusing::help 'option_name'The quotes are important here, it usually works without them, but sometimesyou end up on the wrong page if you omit them.If you're still confused after reading the help page, you know where to ask aquestion ;-)Footnotes1 For example: on 64 bit Windows, the shortcut would look something like this: C:\Program Files (x86)\Vim\vim74\vim.exe -u NONE -U NONE -N. To create it, right click in File Explorer where you want the shortcut, then select New -> Shortcut and paste the shortcut text. You may need to change the Vim path if your Vim is installed in another location.