Kim Schulz wrote:
Hi,
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?
(besides "know your :help" :-) )
ideas could be:
Do's and dont's
best util script
often used functions
ways of optimization
etc. etc..
In addition to what Yakov and Mikolaj have said, and with which I fully agree,
my main advice would be: Your Mileage Will Vary.
- One person's "most used" script might not even be useful for another user.
- A keymap, a colorscheme, a syntax script, a utility script or a vimrc each
require fundamentally different approaches.
One thing Mikolaj mentioned, but which I want to stress: make your scripts as
portable as you can:
- You're on Linux now, but if and when you find yourself facing a Mac or
Windows (or other) machine, you will still want to use Vim the same way.
- Your scripts should work in both Vim and gvim (if at all possible).
- If ever you find yourself using a Vim version with a limited featureset, or
an older version of Vim, you don't want your vimrc (or other Vim script) to
halt on an error because you set an unsupported option or use an unsupported
command (for that version).
This means that IMHO:
* you should test has(), exists() etc. whenever there is a possibility that
some feature might possibly be absent on some version of Vim. (Better be safe
than sorry.)
* if there are several ways to program a single task, use vim-script in
preference to interfacing with perl, python, etc., unless:
(a) you know that the required interpreter will always be available
whenever you will need that task, and
(b) the "alien" version of the script is faster and cleaner than the "vim"
version, or the task at hand cannot be handled with "pure" vim-script.
Best regards,
Tony.