Vim Tips Wiki
(→‎Comments: need plugin manager code)
 
(15 intermediate revisions by 5 users not shown)
Line 1: Line 1:
  +
{{TipNew
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.
 
  +
|id=1676
  +
|previous=1675
  +
|next=1677
  +
|created=September 6, 2011
  +
|complexity=basic
  +
|author=Raimondi
  +
|version=7.0
  +
|subpage=/201109
  +
|category1=Getting started
  +
|category2=Troubleshooting
  +
|category3=Usage
  +
}}
 
Sometimes a basic feature of Vim does not work as expected. The following instructions can help eliminate possible sources of the problem.
   
=Generic troubleshooting=
+
==General troubleshooting==
  +
===Check Vim without customizations===
Sometimes a basic feature of Vim does not work as expected, the following instructions can help to find out where the problem is located.
 
 
Run the following command from your terminal and see if the problem persists (if wanted, replace "<code>vim</code>" with "<code>gvim</code>"):
  +
<pre>
 
vim -N -u NONE -i NONE
  +
</pre>
   
  +
You will need to manually enable anything like filetype detection, syntax highlighting, etc. that are needed to troubleshoot the problem.
==Discard Vim executable==
 
 
*'''If the problem persists''', that means the problem could be in the Vim executable or official runtime files. Go and [[#Verify required features|verify the enabled features]].
Run the following command from your terminal and see if the problem persists:
 
 
*'''If the problem went away''', it is time to [[#Check Vim with just your .vimrc|test your vimrc]].
   
 
===Verify required features===
<pre>vim -N -u NONE</pre>
 
 
Check the feature you need was enabled when Vim was built. Use the <code>:version</code> 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 a Vim version that has them enabled.
 
*'''All needed features are enabled'''. 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.
   
  +
===Check Vim with just your .vimrc===
* '''If the problem persists''', that means the problem could be on the Vim executable. Go and [[#Verify enabled features|verify the enabled features]].
 
 
Run Vim with following arguments and see if the problem disappears:
* '''If the problem went away''', it is time to [[#Discard vimrc| test your vimrc]].
 
  +
<pre>
 
vim -N --noplugin -i NONE
  +
</pre>
   
 
*'''If the problem persists''', the reason of your pain is inside your [[#vimrc|vimrc]].
==Verify enabled features==
 
 
*'''If the problem went away''', the next step is to [[#Check Vim with just your plugins|rule out the plugins]].
Check the feature you need was enabled when Vim was built. Use the <tt>:version</tt> 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 a Vim version that has them enabled.
 
* '''All needed features are enabled'''. 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 with following arguments and see if the problem disappears:
 
vim -N --noplugin
 
* '''If the problem persists''', the reason of your pain is inside your [[#VIMRC|vimrc]].
 
* '''If the problem went away''', the next step is to [[#Discard plugins|discard the plugins]].
 
   
==Discard plugins==
+
===Check Vim with just your plugins===
 
Back to your terminal and run Vim like this:
 
Back to your terminal and run Vim like this:
  +
<pre>
vim -N -u NORC
+
vim -N -u NORC -i NONE
  +
</pre>
   
* '''If the problem persists''', the issue is related to a [[#Plugins|plugin]].
+
*'''If the problem persists''', the issue is related to one or more plugins, [[#Plugins|find out which]].
* '''If the problem went away''', maybe the problem is that Vim is running in compatible mode, verify that with <tt>:verbose set cp?</tt> to also see where it's being set.
+
*'''If the problem went away''', maybe the problem is that Vim is running in compatible mode, verify that with <code>:verbose set cp?</code> to also see where it is being set.
   
=Specific troubleshooting=
+
==Specific troubleshooting==
==Plugins==
+
===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).
 
If you have no idea which plugin(s) might be causing the problem, use a binary search method to isolate the errant plugin(s).
   
Line 44: Line 61:
 
## Consider replacing the plugin with a competing solution.
 
## Consider replacing the plugin with a competing solution.
   
==VIMRC==
+
===vimrc===
NOTE: The [https://github.com/dahu/VimLint VimLint] plugin was designed to help identify erroneous vimrc settings.
+
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 (file <code>~/.vimrc</code> on Linux, or <code>$HOME/_vimrc</code> on Windows).
* Ensure your vimrc contains at least:
+
*Ensure your vimrc contains at least:
  +
<pre>
 
set nocompatible
 
syntax on
 
filetype plugin indent on
 
set hidden
  +
</pre>
   
 
*Ensure your vimrc does '''not''' have:
set nocompatible
 
  +
<pre>
syntax on
 
 
set compatible or set cp
filetype plugin indent on
 
 
set smartindent or set si
set hidden
 
 
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
  +
</pre>
   
 
*If Vim finds the command <code>finish</code> 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.
* Ensure your vimrc does '''NOT''' have:
 
 
*Ensure <code>:echo $SHELL</code> is correct. You will need to use a POSIX shell for full Vim compatibility. The fish shell is known to not be compatible.
 
*Ensure <code>:echo $TERM</code> is correct. Check TermSettings for your terminal type.
   
 
===Mappings===
set compatible or set cp
 
 
A custom mapping may not work because it was overwritten by a plugin. The following command will tell you if <code>aa</code> is mapped to something and, if so, where the mapping was created.
set smartindent or set si
 
  +
<pre>
set cindent or set cin
 
 
:verbose map aa
set lisp
 
  +
</pre>
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
 
   
 
Use the appropriate <code>:map</code> command for the mapping you are testing, see <code>:help :map-modes</code> for more details.
* If Vim finds 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.
 
   
 
===Options===
* 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.
 
 
Many plugins change options when they are sourced, filetype is set, etc. So, you might find yourself wondering why an option is not set as you expect. From inside Vim, type this command:
  +
<pre>
 
:verbose set myoption?
  +
</pre>
   
  +
That displays the value of the given option and where it was set. Replace <code>myoption</code> with the option being tested, and remember to include the "<code>?</code>" (the query causes the value to be displayed; omitting it might set the option).
* Ensure :echo $TERM is correct. Check TermSettings for your terminal type.
 
   
 
For local options that inherit its value, that command would not specify where the value was set. '''What to do in this case?'''
==Mappings==
 
Many times a custom mapping doesn't work because it was overwritten by a plugin. The following command will tell you if <tt>aa</tt> is mapped to something and, if so, where the mapping was created.
 
:verbose map aa
 
 
Use the appropriate <tt>:map</tt> command for the mapping you're testing, see <tt>:help :map-modes</tt> for more details.
 
 
==Options==
 
Many plugins change options when they are sourced, filetype is set, etc. So, you might find yourself wondering why an option is not set as you expect. From inside Vim, type this command:
 
:verbose set option?
 
to know what's its value is and where it was set, just replace option for the problematic option and don't leave the '?' out of the command.
 
   
  +
==Comments==
NOTE: For local options that inherit its value, that command would not specify where the value was set. '''What to do in this case?'''
 
  +
Should explain the use of the <code>-i</code> flag, and also mention that the viminfo file can be the cause of issues (especially slowness in loading apparently).
  +
----
  +
Also need to talk about how to get various plugin managers to start up without your .vimrc when doing -u NORC.

Latest revision as of 23:30, 28 July 2013

Tip 1676 Printable Monobook Previous Next

created September 6, 2011 · complexity basic · author Raimondi · version 7.0


Sometimes a basic feature of Vim does not work as expected. The following instructions can help eliminate possible sources of the problem.

General troubleshooting[]

Check Vim without customizations[]

Run the following command from your terminal and see if the problem persists (if wanted, replace "vim" with "gvim"):

vim -N -u NONE -i NONE

You will need to manually enable anything like filetype detection, syntax highlighting, etc. that are needed to troubleshoot the problem.

Verify required 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 a Vim version that has them enabled.
  • All needed features are enabled. 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.

Check Vim with just your .vimrc[]

Run Vim with following arguments and see if the problem disappears:

vim -N --noplugin -i NONE
  • If the problem persists, the reason of your pain is inside your vimrc.
  • If the problem went away, the next step is to rule out the plugins.

Check Vim with just your plugins[]

Back to your terminal and run Vim like this:

vim -N -u NORC -i NONE
  • If the problem persists, the issue is related to one or more plugins, find out which.
  • If 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 is 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.
    1. 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 back to step 2.
    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 back to step 2.
  3. If you can isolate one or a set of plugins causing the problem:
    1. Make sure you have the latest version of those plugins installed.
    2. Check the plugin page to see if there are any known conflicts with other plugins or known failures for a given Vim version.
    3. Consider replacing the plugin with a competing solution.

vimrc[]

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

  • Ensure you have a personal vimrc file (file ~/.vimrc on Linux, or $HOME/_vimrc on Windows).
  • 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
  • If Vim finds 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.
  • 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.

Mappings[]

A custom mapping may not work because it was overwritten by a plugin. The following command will tell you if aa is mapped to something and, if so, where the mapping was created.

:verbose map aa

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

Options[]

Many plugins change options when they are sourced, filetype is set, etc. So, you might find yourself wondering why an option is not set as you expect. From inside Vim, type this command:

:verbose set myoption?

That displays the value of the given option and where it was set. Replace myoption with the option being tested, and remember to include the "?" (the query causes the value to be displayed; omitting it might set the option).

For local options that inherit its value, that command would not specify where the value was set. What to do in this case?

Comments[]

Should explain the use of the -i flag, and also mention that the viminfo file can be the cause of issues (especially slowness in loading apparently).


Also need to talk about how to get various plugin managers to start up without your .vimrc when doing -u NORC.