|
|
vim/gvim tuneup
|

Go back to home page
|
|
This page provides some tips for configuring vim.
Some small files are available that set highlighting for
Ferret and GrADS scripts.
Also available are some small files
to amend the highlighting for LaTeX
and Fortran 90.
|
last modified:
Something to read
First steps with vim is about using vim/gvim. And you will need
to know how to use it before you configure it.
Something simple to configure
Here is something simple to do.
Every time you invoke vim or gvim, your
.vimrc file in your home directory will be sourced, if you have
one.
I, and many others, find the default tabbing of 8 spaces to be
too wide, especially for working with python.
Let's make a .vimrc file and fix that problem
by including the following two lines:
set tabstop=4
set shiftwidth=4
The value of tabstop controls the visual appearance
of tab spacing within the vim window.
Normally, the value of shiftwidth is the number of spaces vim will insert
in the automatic indentation.
Here both shiftwidth and tabstop have the same value,
so the clever vim will insert one tab character for the indentation. That will
keep python happy.
However, there seems to be an emerging consensus that using tabs to
format source code is not a good idea. You may want to add this line to your .vimrc:
set expandtab
With that, both python and users of your source code will be happy (at least about your
lack of tabs).
Nevertheless, I like tabs. It is easier to delete one tab rather than
four spaces. So I use:
set noexpandtab
I also did not appreciate all the "beeps" that
gvim likes to send my way. So I turn off the beeps with
set visualbell
Getting stuck in vim
Here a list of things newbies might get stuck on.
Advice is given on how to get unstuck:
-
In gvim, stretch the Gui tall. Type <esc>, then :help.
Your gvim window will be split. Clicking the mouse in the top or bottom window will
make that window active (:q quits the window).
We all know how to browse web pages. Successfully browsing
a help file within the gvim editor requires some skill. First, you may want to
surf the online HTML form of help,
which are the same help files that appear within gvim, but in HTML form. That is
easy to navigate, right? The vim form of the helpfile has instructions on
how to navigate; it really does work. Just remember that CTRL-T takes you back...
- You may not realize that you are using only 10% of the capabilities of
vim. For example go to "tips","browse all tips" found at
www.vim.org. At the bottom of the displayed tips,
leave keywords blank and search by rating
descending...
Configuring vim
These instructions are for version 6.1 or greater, as found within Mandrake 9.0.
In the previous section I showed some of the lines I put in my
.vimrc file. Here I show what I configured
recently from my .vim directory within my home directory.
- Within your .vim directory, make a directory after
and after/syntax. Drop my amendment files
fortan.vim
and tex.vim
within your after/syntax directory.
Read the comments within those files to see what they are going to do.
If you want to do the setting of tabstop etc. just for python, then
grab python.vim for your
after/syntax. But if you use it, beware of potential confusion about
what is controlling your python syntax: your .vimrc or your
python.vim?
-
My vim distribution did not have syntax files for Ferret or GrADS, so I
made my own. Within your .vim directory, make a directory
syntax. Drop into .vim/syntax/
ferret.vim and
grads.vim. For vim to
use these files, it will need to recognize the appropriate filetype
extension, .jnl and .gs.
This recognition can be set in your .vim/filetype.vim file.
Here is what I have in my filetype.vim.
- SpellChecker
is a godsend. By the way, it is also
available from the developer's vim page
vim page of Ajit J. Thakkar
Now, after it is installed, type :help SpellChecker.
In :help SpellChecker-Usage you will see commands can
be executed by key mappings which are prefaced with a "<Leader>", which
is "\". For example, "\sc" toggles SpellChecker on/off. Note
that for these key mappings to work, you must be in normal mode
(hit ESC to be in normal mode). Most importantly, the three keys
must be typed rapidly in succession.
- VIM version 6.1 will already have a distribution for syntax
highlighting of Fortran 90. Check that fortran.vim is
found within /usr/share/vim/syntax. My .vimrc
shows how I configure the assumptions of F90/F77.
- colorize.vim
is a nifty utility for newbies. Read the comments within, and heed the
instructions for Unix/Linux. Here is my .gvimrc,
after the installation. To learn more about .gvimrc, look
within /usr/local/share/vim or /usr/share/vim for a file
gvimrc_example.vim.
|