I have a problem in Vim, and I think it may be in my
vimrc file (or have been told it could be my
How do I verify this? If it is my
vimrc file, how do I know where exactly the problem lies?
The first thing you want to do is to start Vim with the default settings:
vim -u NONE -U NONE -N
-u NONE prevents Vim from loading your vimrc,
-U NONE prevents Vim from
loading your gvimrc, and
-N tells Vim to use no-compatible mode (this isn't
required, 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 vimrc file.
Hurray! Go and ask your question. Be sure to mention that you tried starting Vim without a vimrc file!
If you haven't already, you probably want to save a backup copy of your vimrc file first.
The next thing you probably want to do is disable all plugins first; plugins can
alter quite a bit in Vim. If this fixes the problem, then try to find out
which plugin by re-enabling them one-by-one. After you've found out which
plugin exactly causes the problem, you can try & fix it by reading this plugin's
documentation, and/or by asking a question tagged with
If it's not a plugin, and you don't have any idea what's causing your problem, then it's a trial-and-error procedure. Comment out one or more lines in your vimrc, start Vim, check if the problem occurs, and repeat this procedure until the problem stops occurring. The fastest way of doing this is:
In the end you should have a single option or a combination of a few options that causes your problem. You can find out more about any option in Vim by using:
The quotes are important here, it usually works without them, but sometimes you 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 a question ;-)
If you want to isolate a single plugin, perhaps to ask a question about it, you want to load as little as possible but still load the plugin; you can easily do this with Vim's packages feature. This requires Vim 8 or a reasonably recent version of Neovim.
Create a new empty directory; we'll use the
~/plugin path in this example.
Now put the plugin in the regular
pack/plugins/start/$name directory. For
git clone https://github.com/fatih/vim-go.git ~/plugin/pack/plugins/start/vim-go
test-vimrc file with the following contents; this will ensure that
Vim will load plugins from the
~/plugin directory and not the
set nocompatible set packpath=~/plugin,/usr/share/vim/vimfiles,/usr/share/vim/vim80,/usr/share/vim/vimfiles/after,~/plugin/after packloadall! syntax on filetype plugin indent on
Start Vim with:
vim -U NONE -u ~/test-vimrc
You now have a minimal vimrc with just this single plugin.
1 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.
-D Vim parameter specially for debugging which will go to debugging mode after executing the first command from a script.
E.g. to run Vim in debug mode without any plugins, run as:
vim --noplugin -D
next to parse the next line and keep pressing Enter.
q to go back to
If you're using a GUI version, put a
gui command in your vimrc to start the debugging right after that command.
Press Ctrl+d for list of available commands
One more tip: as caveman as it may seem, I do like adding :echom "message" to my .vimrc to see whats being executed and what is not.
if executable('ag') :echom "AG FOUND" ... endif
This helps me quickly see if the if block is being executed, etc. The message will be printed on the console next time you start vim.
One thing that I've found helps is keeping a collection of variables that toggle parts of your
.vimrc so you can disable or enable portions of it without having to comment stuff out. It also has the pleasant side effect of forcing you to think about the organization of your
" feature toggles in vimrc let g:vimrc_feat_pathogen = 1 let g:vimrc_feat_core_minimal = 1 let g:vimrc_feat_matchit = 1 let g:vimrc_feat_options = 1 let g:vimrc_feat_colors_and_highlight = 1 let g:vimrc_feat_key_rebinding_arpeggio = 1 let g:vimrc_feat_key_rebinding = 1 let g:vimrc_feat_autocommand_group = 1 let g:vimrc_feat_custom_definitions = 1 let g:vimrc_feat_load_opam = 1
Here's an example of a section guarded by an
if g:vimrc_feat_core_minimal set nocompatible filetype plugin indent on syntax on endif
As already mentioned, first try
vim -u NONE -U NONE -N to make sure your vanilla vim is working fine.
Then start vim normally and check
from inside vim after the problem, which will show all warnings and errors.
Finally start vim with the following command
which will create a logfile called
-V9 is the logging level and try to reproduce your problem.
Here is a vey simple procedure to get you started.