I use Vim (i.e. Vi Improved) as my usual editor. I've been using it
since I first started using linux about 7 years ago (it was a concious
choice not to use Emacs, mostly because I wasn't coding and wanted to
be "different" from my friends who were doing computer science). My
habit has always been pure vim, none of the
Gtk+ nonsense with X mouse capture and such.
Unfortunately, after 6 or 7 years, I am still not a power-user.
Without a copy of my vim cheat-sheet, I can only open a file, hit 'i'
to enter insert mode, edit the file, use the visual mode for
copy-cut-past (or, in vimspeak,
yank-delete-put), do simple searches and replacements,
and save the file. Most of the advanced operations are beyond me.
A few months ago (mark it February of 2008) I started doing a
little bit of coding, and discovered the usefulness of split windows
and folds in vim. (The former is particularly useful
since I often run my laptop without X and the console
display is 160x50, so split-view gives two nice columns.)
After exploring for a bit, I figure that I might try to fix-up my
vim using habits to make myself more productive when I do
something that I do a lot of: writing papers and lecture notes in
LaTeX. While I do know about Vim-latex, I find it too
big and complicated, and furthermore, as I hit my quarter-century
mark, I find myself too old to remember all the key mappings. It would
be, of course, easier to remember mappings that I defined myself. So I
wrote down some custom mappings and stuck them in my
vimrc.
Here is the file. I stick
it in ~/.vim/custom/ and insert the line
runtime custom/latexcustom.vim
in my ~/.vimrc. (I don't bother to do a switch on
BufRead since over 90% of the files I edit are
LaTeX files and I don't have any other key-mappings
defined that might be confusing.)
A quick anatomy of the file
Dvipreview() which
displays the DVI file and allows forward searches (from the .tex file
to the .dvi file) if one includes the srcltx
package in the .tex file.
SimpleTexFold() function which is called on
BufRead of a .tex file to create manual folds. I fold all
the LaTeX preamble (up to \begin{document})
in one fold, and each of the \section in a fold. I do
this (regenerating folds on load instead of saving folds between
writes) because I often edit the same file on different computers, so
saved folds don't always work. When I have some free time I will try
to make the folds more intelligent and do \subsection as
well.
F2 is mapped to save and compile the current file. I
still need to figure out how to gracefully exit when there's an error
and how to display the error. (I choose F2 from habit
from my BASIC days when F2 was mapped to
RUN.)
F4 is mapped to call Dvipreview()
F5 is mapped to insert environments. The current word
under the cursor will be turned into the environment name for a
\begin{..}...\end{..} environment. For example, I can
type align*<F5&rt; and it will become
\begin{align*} \end{align*}. This helps me from
forgetting to close the environments and is really useful when I have
many nested lists as when I type my lecture notes.
F6 is mapped to escape the current environment.
F7 searches backward through the document for a
\labal{..} whose text begins with the word under the
cursor.
F8 continues the search.
F9 takes the found label and insert it as a
\ref{..} where the search began. These last three
commands are to help me create cross references of equations and
theorems in a document.
More improvements will be added as I go along.