Vim Tips Wiki
No edit summary
Line 47: Line 47:
 
NOTE: The [https://github.com/dahu/VimLint VimLint] plugin was designed to help identify erroneous vimrc settings.
 
NOTE: The [https://github.com/dahu/VimLint VimLint] plugin was designed to help identify erroneous vimrc settings.
   
# Ensure you '''have''' a personal vimrc file. In linux, your vimrc file is located at $HOME/.vimrc and in Windows it's $HOME/_vimrc or $VIM/_vimrc
+
* Ensure you '''have''' a personal vimrc file. In linux, your vimrc file is located at $HOME/.vimrc and in Windows it's $HOME/_vimrc or $VIM/_vimrc
# Ensure your vimrc contains at least:
+
* Ensure your vimrc contains at least:
   
 
set nocompatible
 
set nocompatible
Line 55: Line 55:
 
set hidden
 
set hidden
   
# Ensure your vimrc does '''NOT''' have:
+
* Ensure your vimrc does '''NOT''' have:
   
 
set compatible or set cp
 
set compatible or set cp
Line 69: Line 69:
 
set nomodeline or set noml
 
set nomodeline or set noml
   
# Ensure :echo $SHELL is correct. You will need to use a POSIX shell for full Vim compatibility. The fish shell is known to not be compatible.
+
* Ensure :echo $SHELL is correct. You will need to use a POSIX shell for full Vim compatibility. The fish shell is known to not be compatible.
   
# Ensure :echo $TERM is correct. Check TermSettings for your terminal type.
+
* Ensure :echo $TERM is correct. Check TermSettings for your terminal type.
  +
  +
* If Vim find the command <tt>finish</tt> anywhere in your vimrc it will stop sourcing the rest of the file. So you can use it to do a binary search as described in [[#Plugins|Plugins]] to identify the problematic line.
   
 
==Mappings==
 
==Mappings==

Revision as of 04:16, 12 September 2011

This is a draft and any contribution is welcome. Feel free to add, change or comment anything. It'll remain under my user area until it's useful.

Generic troubleshooting

Sometimes a basic feature of Vim does not work as expected, the following instructions can help to find out where the problem is located.

Discard Vim executable

Run the following command from your terminal and see if the problem persists:

vim -N -u NONE

Verify enabled features

Check the feature you need was enabled when Vim was built. Use the :version command to see if that feature is enabled.

  • Some/any needed features are disabled. Build Vim with desired feature enabled or use your package manager to install it.
  • All needed features are enabled. What to do here?
  • Consider 3rd party libraries. For example, the command-T plugin requires that your system ruby be the same as that which was linked with Vim.

Discard vimrc

Run vim -N --noplugin and see if the problem persists.

  • The problem persists. The reason of your pain is your vimrc.
  • The problem went away. The next step is to discard the plugins.

Discard plugins

Run vim -N -u NORC and see if the problem persists.

  • The problem persists. It looks like the issue is related to a plugin.
  • The problem went away. Maybe the problem is that Vim is running in compatible mode, verify that with :verbose set cp? to also see where it's being set.

Specific troubleshooting

Plugins

If you have no idea which plugin(s) might be causing the problem, use a binary search method to isolate the errant plugin(s).

  1. Disable half of your plugins and retest Vim.
  2. Test again to see if the problem persists or has gone away.
  • If the problem went away, the disabled set contain your bad plugin. Keep half of the disabled plugins disabled and re-enable the other half. You now have less disabled plugins to test. Go to step 2.
  • If the problem persists, the enabled set contain your bad plugin. Disable half of your remaining plugins and keep the other remaining half enabled. You now have less enabled plugins to test. Go to step 2.
  1. If you can isolate one or a set of plugins causing the problem:
  • Make sure you have the latest version of those plugins installed.
  • Check the plugin page to see if there are any known conflicts with other plugins or known failures for a given Vim version.
  • Consider replacing the plugin with a competing solution.

VIMRC

NOTE: The VimLint plugin was designed to help identify erroneous vimrc settings.

  • Ensure you have a personal vimrc file. In linux, your vimrc file is located at $HOME/.vimrc and in Windows it's $HOME/_vimrc or $VIM/_vimrc
  • Ensure your vimrc contains at least:
 set nocompatible
 syntax on
 filetype plugin indent on
 set hidden
  • Ensure your vimrc does NOT have:
 set compatible      or    set cp
 set smartindent     or    set si
 set cindent         or    set cin
 set lisp
 set gdefault        or    set gd
 set edcompatible    or    set ed
 set exrc            or    set ex
 set insertmode      or    set im
 set noloadplugins   or    set nolpl
 set nomagic
 set nomodeline      or    set noml
  • Ensure :echo $SHELL is correct. You will need to use a POSIX shell for full Vim compatibility. The fish shell is known to not be compatible.
  • Ensure :echo $TERM is correct. Check TermSettings for your terminal type.
  • If Vim find the command finish anywhere in your vimrc it will stop sourcing the rest of the file. So you can use it to do a binary search as described in Plugins to identify the problematic line.

Mappings

If a custom mapping doesn't work many times that's because it was overwritten by a plugin. :verbose map aa will tell you if aa is mapped to something and, if so, where the mapping was created.

Use the appropriate :map command for the mapping you're testing, see :help :map-modes for more details.

Options

Many plugins change options, so you might find yourself wondering why an option is not set as you expect. Use :verbose set option? to know what's its value is and where it was set, just replace option for the problematic option and include the '?' in the command.

Note that that local option inherits its value, that command would not specify where the value was set. What to do in this case?