Mark's VIM Page
Contents: | Huh? What's VIM? | VIM Web Resources | My VIM Files | My Resources | VIM Tips |
I want to provide my own suggestions or help for VIM at this site as well as provide
a method to download syntax files that I maintain.
I copied the format and some source for this page from Adrian Nagle's VIM page
because he did a good job and I don't do much HTML.
VIM is a free text editor that is based on the popular vi editor and is
available on just about every platform. I have it working on my Linux machine at home
as well as my NT4.0 machine at work. VIM, which stood for Vi IMitation, is
more than based on vi, setting the compatible option in
VIM will make VIM emulate everything in vi including some of the bugs! Through
much hard work from many folks on the Internet, VIM has been improved greatly
adding many new features and improving existing functions from the original vi.
It makes sense that VIM now stands for Vi IMproved.
Some of the features of VIM version 5.6 are listed below:
This is just a taste of some of the features of VIM. To learn more about VIM
or to find other syntax files, I suggest you check out the
VIM page! This site contains up to date
information on VIM with links to the latest distributions for any system of
- Syntax highlighting, of which you can define your own.
- Autocommands, automatically execute commands at certain
events like saving a file.
- Multiple windows or files in one editing session.
- Mappings, map functions or key sequences to any key(s).
- GUI support for some systems.
- Long undo history.
- Automatic support for both UNIX and MS-DOS file formats.
- Macros, quickly "record" key sequences that you want to repeat.
- Visual mode, to highlight text to operate on (delete, copy, etc.)
- Command line, now has a history and easy editing as well as a
command/filename completion feature.
- Scripts can use expressions and other functions.
- Easily load in include files into a new buffer.
- Highlight search results.
The following are VIM files I have created to speed up software development.
They are primarily for C++ though there is a little lisp and a little java mixed in.
I also included my .vimrc for help or as a starting point. I created my .vimrc
with inspiration from Sven's .vimrc found at the official VIM page.
- .vimrc personal rc file
- C.vim C++ source file auto-template.
- h.vim C++ header file auto-template.
I developed templates for several C++ development files above. They provide the
basics that any C++ file would require, including class skeleton, copyright, cvs
tags, and change log. The templates are easily modified for the needs at hand.
These templates automatically create a basic C++ source or
header file for your project. They dynamically fill in the copyright year, date
and userID of first modification, and project name where necessary. The project
name is based on the name of the file created. With the lines below added to
your .vimrc, these will run when you tell VIM to open a file with the
appropriate extension and that file does not exist. To add these templates to
- First, copy the template files to your desired location. I store mine in
my $VIM/templates directory which I created. The templates files are:
C.vim C++ source file auto-template.
h.vim C++ header file auto-template.
- Next, add the following to your .vimrc.
" Remove all template autocommands
autocmd BufNewFile *.C source $VIM/templates/C.vim
autocmd BufNewFile *.h source $VIM/templates/h.vim
I am slowly learning key mapping and autocommands in VIM. The following are
some of my attempts to make life easier using VIM. I've included where to
look in the on-line help where appropriate. You can simply type :help
abbreviations, for example.
- Converting the case of a word
- To convert a word under the cursor to upper case, type viwU.
- For lower case, type viwu, or to flip the case, type viw~.
- Searching for the word under the cursor
- To search for the word currently under the cursor, type *.
- To search backward for the word under the cursor, simply type #.
- To repeat or reverse the search, just use n or N as you normally would.
Macros are key bindings you can place in your .vimrc file to add functionality.
- Splitting the VIM screen
- You can view multiple files or sections of files simultaneously in a single instance of VIM.
- To split the current file into two panes, type :sp.
- Switching panes is done by typing ^W^W (ctrl-w ctrl-w).
- To split the screen into two panes with a different file in the new pane, just add the filename after the split command (e.g. :sp myFile).
- VIM will normally split the screen equally, but you can specify the size of the new pane with a number before the command (e.g. :10sp for a ten line pane).
- The normal split command splits the screen horizontally. VIM 6 adds a new
vertical split command (:vsp) with the same functionality.
- Searching for a highlighted string
- To search for a highlighted string just as you would search for the word under the cursor, use the following macros:
vnoremap * y/<C-R>=substitute(escape(@@,"/\\"),"\n","\\\\n","ge")<CR><CR>
vnoremap # y?<C-R>=substitute(escape(@@,"?\\"),"\n","\\\\n","ge")<CR><CR>
- You may now select text in visual mode (e.g. by typing v or using the mouse) and use * and # as described in the General Tips above.