Tip #411: How to initialize plugins
tip karma |
Rating 132/42, Viewed by 6124
|
created: |
|
January 23, 2003 6:52 |
|
complexity: |
|
basic |
author: |
|
Charles E. Campbell, Jr. |
|
as of Vim: |
|
6.0 |
Plugins have two basic ways of being initialized:
a) via some variable that the plugin script uses;
the initialization here is obvious -- set the
desired variables in your <.vimrc> (or use
an appropriate autocmd to do so).
b) via a map or function call. The problem here
is that <.vimrc> is sourced prior to plugin
sourcing, so the map or function call isn't
available yet.
Solution: put in .vim/after/plugin a file
of the same name as the plugin you're initializing.
In that file put
call TheInitializationFunction()
-or-
norm TheInitializationMap
For example, the <HiMtchBrkt.vim> script which supports the
highlighting of matching brackets as you move onto a
bracket is not on by default. Normally it requires one to
type "\[i" to start it. However, if you'd like to have the
script to start enabled, then put
norm \[i
into the file <.vim/after/plugin/HiMtchBrkt.vim> (see tip
vimtip#177).
(Windows users: mentally change .vim to _vimfiles and / to \
in the tip above)
<< Allow Inform header files to be distinguished from C headers |
Easy menu-style switch between files with a simple map >>
Additional Notes
[email protected],
March 6, 2003 12:45
|
just wanted to say that i use the windows version, and i had to goto the directory vim/vim61/plugin, and i added the line
norm \[i
at the very end of the file HiMtchBrkt.vim
also when i opened a file, an annoying window popped up, so i commented out the echo command at line 108 of the file.
boonth
|
[email protected],
March 17, 2003 12:24
|
The fix for that annoying little message box is to use:
silent norm \[i
The box no longer shows up. Enjoy!
|
[email protected],
October 4, 2003 7:20
|
I'm trying the plugin with those old FORTRAN progrms I work with.
Most lines start with tabs, and the pligin seems to get confused by this fact.
If I replace the tabs by spaces it works fine, even witn multiline sentences.
Juan Lanus
TECNOSOL Argentina
|
[email protected],
May 25, 2005 13:26
|
I've successfully used this approach to have SeeTab.vim vimscript #628 automatically load by putting in the line:
execute "SeeTab"
in my after\plugin\SeeTab.vim file with the original SeeTab.vim file in plugin\SeeTab.vim.
This works ok while gvim is open, but I get an error message when exiting:
"E254: Cannot allocate color ."
How can I make this error not show up?
If I don't auto-load using the execute line, but instead type in the "SeeTab" command after gvim starts, then the error does not appear when exiting.
I'm using gvim 6.3 on WinXP.
I'm also using blockhl.vim vimscript #104 if that might be causing any conflicts.
|
|
|