Hello,

* On Sat, Dec 02, 2006 at 07:05:40PM +0100, Kim Schulz <[EMAIL PROTECTED]> 
wrote:
> It you should give one (or more) tips to a person who was going to
> start creating scripts for vim, then what would it be? 

Tough question.

> ideas could be:
> Do's and dont's 

* Do know the various kinds of scripts (plugins, ftplugins, compiler
plugins, indent plugins, ...).

In particular |ftplugins| can be seen as buffer-wise plugins dedicated
to specific type of files.
    :h map-local
    :h b:var
    :h :setlocal
BTW, b:did_ftplugin is not to be used by us, mere mortals. This
anti-reinclusion guard must be reserved to "standard" ftplugins. For
instance, they can't be of any help in my C++ ftplugins suite as it is
made of several distinct C++ ftplugin scripts (and many other plugins,
auto-plugins (VimL functions dedicated to C++ analysis (scopes,
signatures, ...) , ...) 



* Don't assume anything about the configuration of the users of your
scripts. 
This means that vim versions can vary, and even the way vim is compiled
can make some differences as it has already been said in this thread.

Moreover, sometimes people override standard keys sequences to do, well,
quite odd things that have nothing to do with the standard and default
behavior we can expect.
This means we, plugins writers, must always prefer the "nore" version of
:*map, :*abbr, and :normal! over :normal. Unless it can't be done
otherwise.


In the same kind of idea, our users may not like the default keybindings
we propose for our mappings. Instead of having them patch by hand our
scripts (that they may have to upgrade for a newer version someday),
we have to consider using |<plug>|, |<Leader>|, and other global options
(|g:var|), all three to be set from within the .vimrc.


> best util script

I use a lot the scripts I'm maintaining (searchInRuntime,
BuildToolsWrappers, my fork of mu-template, my bracketing suite). But
also a few other scripts like a.vim, enhancedCommentify, CVS-menu,
Matchit, swap-words, ...

Lately, I've started moving a few functions to autoload plugins, which
are perfect to implement VimL library plugins.

> often used functions

substitute(), match*(), exists(), ...
But also :exe, :normal!, I-CTRL_R, :s, ... which are not functions
indeed.

> ways of optimization
> etc. etc..

A couple of years ago, I gave a presentation of vim configuration. The
slides are available on my web site [1], they are in French and pre-date
the release of vim7 which changed a few things in the way I develop my
plugins. The few examples, and references to vim help topics should be
understandable.

SVN is my precious friend, even if I haven't moved all my scripts into
subversion repositories.

Having a documentation that also stats the purpose of your scripts is
plus.

HTH,

[1] http://hermitte.free.fr/vim/ressources/vim-config.pdf
-- 
Luc Hermitte
http://hermitte.free.fr/vim/

Reply via email to