Vim Dr Chip's Vim Page Vim

Author: Charles E. Campbell
Copyright 2012


Ten Most Recent Script Updates

ScriptVersionDate
RunView v4f Mar 03, 2022
vis v23a Sep 08, 2016 - Dec 08, 2021
vimball v37 Apr 11, 2016
gdbmgr v2 Jan 07, 2020
manpageview v25w May 03, 2016 - Aug 31, 2022
vissort v5 Apr 16, 2013
zip v33 Mar 12, 2023
VisCdecl v1b Oct 26, 2006 - May 11, 2023
netrw v174b Jun 19, 2023
tar v33g Jul 06, 2023

Welcome to my Vim Page. Herein you'll find a number of scripts, some source code (needs compiling, but I do have pre-compiled executables for you PC types), and Vim syntax files. If you'd like to know more about Vim, check out Vim Online. The syntax files below are often snapshots of my working copies, so sometimes they may be works-in-progress. Usually such files will say ASTRO-ONLY somewhere in the top four lines of the file. In any case, the scripts here will be more up-to-date than the versions, if any, that I put on vim.sf.net.

If you'd like to be on the cutting edge of Vim, may I suggest reading Getting the Vim source with Mercurial.

Nearly all scripts herein will be using the vimball archive format (*.vba files) which first became available with vim 7.0 -- it provides for better installation and automatic helptag generation. If there's a "vba" suffix, you'll need vim 7.0 or later! Vim 7.0 users, however, do need to get a new version of (vimball); vim 7.1 users already have a sufficiently up-to-date version of vimball.

Layout: This admittedly long page is organized into the following format: Contents, Subpages, and Links. Subpages, which cover specific topics, are separated by horizontal lines and have links to the Contents and Links at their bottom right. A few subpages also provide links to more complete webpages (ex. "Color Scheme"). Typically subpages will also provide a link to "Links" in or near their first sentence; this Link goes near where the associated script, code, etc is in the Links section.


Contents

Section
"Abbreviations" for C
C/C++ Code Beautifier
C/C++ Functions: prototypes, hints, etc
Color Scheme
Columnizing
DrChip's Links to Tips and Scripts
Patches
PC: Pre-Compiled Executables
Short Vim Command List
Spelling Checker
Tag Generation
Text and Declarations Alignment
Useful Maps
Vim Versions and Features
Vim Functions, Plugs, and Stubs
Links

Home Page Contents Links

"Abbreviations" for C

Normally with abbreviations one has to type a space to kick off the abbreviation. I wanted to put in stub-like bits of code for common C constructs such as if, for, etc. Well, instead of an abbreviation, I rather like the following solution: use an inoremap on "`" and have it examine the previous word to decide what to do. If you'd like to try it out, click on Dr Chip's C Abbreviations (also listed as Stubs).

Shorthand Longhand
Map Map
i` if`
e` else`
ei` elif`
f` for`
w` while`
s` switch`
c` case`
d` default`
do`

There are also maps for E`, R`, and D` which generate DrChip's debugger calls.

This approach allows your cinoptions to be effective, so you get the indentation style you prefer (abbreviations prevent this). So, if you use my stubs file, you probably should set the cino option. That way the stub will be indented in your style. I've included a copy of my cinoptions below; feel free to incorporate them (my style is the best, of course!) and change them as you will (aw, shucks).

set cino=>s,e0,n0,f0,{0,}4,^-1s,:0,=s,g0,h1s,p2,t0,+2,(2,)20,*30

>s add 1 shiftwidth on normal indent
e0 add 0 to prevailing-indent if '{' not at start-of-line
n0 add 0 to prevailing-indent for statements after if/while/etc, if statements not inside {}
f0 first opening { of a function/block is placed in column 0
{0 opening braces are placed 0 characters from prevailing indent
}4 closing braces are placed 4 characters from the matching opening {'s indent
^-1s add -1 space to prevailing-indent if opening brace is in column 0
:0 case labels are placed 0 characters from switch()'s indent
=s statements after a case label are placed 1 shiftwidth from indent of label
g0 c++ scope (public, private, etc) placed 0 chars from indent of block they're in
h1s c++ statements after public/private/etc 1shiftwidth in
p2 k&r function-argument parameter declarations placed 2chars in from margin
t0 types for function declaration indented flush with margin
+2 continuation lines (split lines) are indented an additional 2 spaces
(2 when in unclosed parentheses, indent two spaces
)20 unclosed parentheses will be searched for at most 20 lines away
*30 unclosed comments will be searched for 30 lines away

Home Page Contents Links

C/C++ Code Beautifier

The <ccb> program (get ccb source here) beautifies C and C++ code. Be careful -- this program does change indentation and can move curly braces around, but if it still has a bad bug, it could damage your source if you use the -r flag (replace). That's why this program is labelled Use At Your Own Risk!. The -s flag is much safer; it saves the beautified versions in *.cb files. Make sure that the beautified source is ok before doing anything irretrievable with your original source code. That said, it does work for me, and normally produces output close to my own preferred style. The "standard" cb style can be obtained with -cdfi. Now that I've released it to the World, I expect some bug reports to crop up (hopefully no really awful ones).

ccb has been on my website since May 25, 2000 with no runtime bugs reported!

Home PageContents Links

C/C++ Functions: prototypes, hints, etc.

Intro: Flist is a program which does a number of things with C/C++ source files' functions: use it to generate listings of functions, prototypes, calling trees, tags, and more ( get flist source here)! You may find the maps in flistmaps a help in using flist with the current file in Vim.

Hints: Flist's -h option makes <hints> files. After you've used flist to generate your hints file, just source it into your editing session or put the following code into your <.vimrc> for automatic sourcing of hints:

if filereadable(expand("hints")) au BufNewFile,BufReadPost *.c,*.C,*.cpp,*.CPP,*.cxx so hints<CR> endif

The result? Every time you type a function name, a prototype for it will appear on the information line. In order to see it, you should set your cmdheight to 2 or more (:set ch=2) and possibly have showmode off (:set nosmd).

Maps: Along with flist itself I've provided a small set of maps which use flist. The maps take the form \[px][pxgs]: prototype or extern, and prototype, extern, global, and static. The map invokes flist against the current file and inserts a list of (global/static/both) prototypes or extern-style function declarations. The \pc map inserts a list of prototypes suitable for inclusion in a comment.

Source Trees: Flist's -Tg option builds a tree-like graph of function use. Coupled with the Flist-based Tree plugin for vim 6.0 or later, one can browse the calling tree on the left hand side of the screen, select a function to edit by putting the cursor on its line, and hitting return. Put <FlistTree.vim> into your plugin directory; you may then use the command :Flist [filename(s)] to begin graph-tree editing. See the usage notes in <FlistTree.vim> for more commands! Click for a screenshot if you'd like to see it first.

Dummy Functions: Flist includes a -D option, which generates "dummy" function definitions. In order to make trees, flist makes a pass over all the source files to determine what functions are present, and then a second pass to determine what functions are called by what functions. Thus common functions (such as printf) are ignored, and the structure of your program is usually better revealed. However, if you want to know where such functions are called, or functions that were defined in your own personal library, you may wish to set up a <dummy.c> file containing a list of such functions with no body (or even arguments). That way flist will process the dummy file quickly. The -D option allows one to generate such a dummy file easily from real ones.

Calling Options Explanation
flist *.c list functions in files
flist -d *.c generate a <ctags> file
flist -e *.c generate an <etags> file
flist -h *.c generate a <hints> file
flist -p *.c list prototypes
flist -t *.c list of functions for inclusion in a comment
flist -x *.c list functions as externs
flist -Ta *.c list calling tree, all roots
flist -Tg *.c "graphical" calling tree
flist -Tf *.c functions found report
flist -Tu *.c functions used/called-by report
flist "?" help
Home PageContents Links

Color Scheme

I've included Vim-script which implements my choice for syntax highlighting. Please check out my page on DrChip's colorscheme for the colorscheme I use. I like keeping the same colorscheme for both gui (gvim) and console (vim); the latter restricts the number of colors available, so such dual-use colorschemes must needs be designed for the limitations of the console.

Home PageContents Links

Columnizing

Ever wished to convert a list of words into a multi-column list (such as ls produces)? Mcol will do that for you (see below), and check out some of my mcol-using scripts.

+---------+------------------------------------------------------+
|Original |   Using ma on "one", moving to "six", and typing \mn3|
|List     |            map \mn3  0!'amcol -n3<CR>                |
+---------+------------------------------------------------------+
|one      |                                                      |
|two      |                                                      |
|three    |            one      three      five                  |
|four     |            two      four       six                   |
|five     |                                                      |
|six      |                                                      |
+---------+------------------------------------------------------+
Home PageContents Links

DrChip's Links to Tips and Scripts

Scripts

Stable Release at Alpha/Beta Release
SourceForge on this Website Description
aftersyntax AFTERSYNTAX allows multiple after/syntax/[lang]/files.vim
Align ALIGN alignment by multiple separators
AnsiEsc ANSIESC highlighting by ansi escape sequences plus concealment
AsNeeded ASNEEDED loading vim scripts on demand
astronaut ASTRONAUT same syntax highlighting for console and gui
AutoAlign AUTOALIGN auto-alignment of =: = etc as one types
blockhl BLOCKHL highlighting of {} level for C/C++
--- CALUTIL calendar utilities
--- CECMATRIX matrix calculator for vim
cecscope CECSCOPE command and menu driven cscope interface
cecutil CECUTIL some utilities used by other of my scripts
--- CLISTFUNC generates a menu of functions for C
--- COMPILING quickfix error formats and checker
--- CTAGEXPL explorer for ctags
CVSconflict CVSCONFLICT CVS conflict resolution using vimdiff
Decho DECHO supports script debugging
--- DOTFILL table of contents dot filler
DrawIt! DRAWIT ascii line drawing (lines, ellipses, fills, etc)
drc_indent DRCINDENT various indent files
drcstubs DRCSTUBS ftplugins to support quick and easy language constructs
EasyAccents EASYACCENTS making accents easy
engspchk ENGSPCHK spelling checker
ephtml --- extended perl html syntax highlighting
--- FLISTTREE graphical function usage tree (for C)
foldcol FOLDCOL inline fold a visual block (column)
--- FUNCSRCH searches restricted to a C function
--- GDBMGR interface between vim and Gdb
GetLatestVimScripts.vim GETSCRIPT how to keep your scripts from vim.sf.net up-to-date
gvcolors GVCOLORS displays X colornames in their own colors
--- HDRTAGEXPLORER explorer for hdrtag
--- HELP extra help file syntax highlighting
hicolors HICOLORS display current highlighting scheme colors + colorscheme editor
HiCurLine HICURLINE Highlights the current line
--- HIGHLIGHT highlights current line
--- HILINKS displays syntax and highlighting labels for cursor position
--- HIMARKS highlights marks using signs feature
--- HIMTCHBRKT Highlights the current line
hints_man2.vim HINTSMAN2 Hints for C Library Functions (man2 based)
hints_man3.vim HINTSMAN3 Hints for C Library Functions (man3 based)
hints_gsl.vim HINTSGSL Hints for GSL Library Functions (1.14 based)
LargeFile LARGEFILE Edit large files quickly
--- LIBVIEW visualizes contents of a library
logiPat LOGIPAT Boolean Logic Patterns
--- MAINTAINER display maintainer of syntax highlighting
--- MANPAGEVIEW vim-based manpage viewing
maplesyrup MAPLESYRUP indenting, autoalign, and matchit support for Maple V
math MATH Math keymap and a menu for inserting math symbols
mathify MATHIFY Transform visual selections into math symbols
--- MCOL multi-column listing
Mines MINES a game
--- MPAGE show file in multiple windows
mrswin --- a toggling version of mswin.vim
netrw NETRW Network Oriented Reading and Writing
--- NETRWCLEAN remove netrw-related files
--- RAINBOW displays matching [] () {} in rainbow colors
--- RLTVNMBR relative numbering using signs
--- RNDM pseudo-random number generator
RunView RUNVIEW Run scripts through filter and display output in separate window
SeeTab SEETAB makes tabs visible as alternating bars
--- STLSHOWFUNC shows current function name in status line
--- SUM computes sum of numbers
--- SWAPSTRINGS swaps two strings
--- TAR handles tar files (also distributed with vim)
--- TEXMAPS LaTeX stubs
--- TWL toggle horizontal/vertical window layout
vimball VIMBALL vim-based archiver builder and extractor
vis VIS VisualCommands, Substitutes, and Searches
--- VISCDECL uses cdecl to explain C declarations
visincr VISINCR visual-block based incremented lists
--- VISSORT sorts visually selected lines
--- VISSWAP swaps visually selected text
WhereFrom WHEREFROM helps one locate where maps, scripts, and functions are defined
--- WINRING implements a "kill ring" for a vim window
--- ZIP handles zip files (also distributed with vim)
--- ZMAPS various extra zX maps
ZoomWin ZOOMWIN zoom into a window, zoom out to all windows

Tips

Swapping characters, words, and lines
Alignment: =, LaTeX tables, declarations, etc
Applying substitutes to a visual block
Deleting a buffer without changing your window layout
Generating a column of increasing numbers
Getting the official distribution's latest: syntax highlighting, runtime, docs, plugins, etc
How do I get rid of that bold stuff with my xterm?
How to initialize plugins
How to overwrite a visual-block of text with another such block
How to sort using visual blocks
How to tell what syntax highlighting group *that* is!
How to toggle between all vertical and all horizontal window layout
How to write a plugin
Maps, Commands, and Functions - some examples of their interplay
Opening gvim atop a console window
Repeating a substitute from current cursor position
Restore cursor to file position in previous editing session
Using vim as a man-page viewer under Unix

Home PageContents Links

Home Page Contents Links

PC: Pre-Compiled Executables

I've included some pre-compiled executables for the PC for which I used a Borland C/C++ compiler (under Miscellaneous in the Links). As a bonus, I've thrown in my calculator program, too. You should still get the source code distributions; if you have ansi escape sequences enabled for your MS-DOS windows, and have <rdcolor.dat>, prompts and help will come up in color. The copyright notices associated with the source distributions also still apply to the executables.

Home PageContents Links

Short Vim Command List

If you've gotten here, I'm sure you realize that Vim has a large number of commands -- that is, commands that one can do while in normal mode. That's not counting the command mode commands! Check out the Real Short Vim Normal-Mode List of Commands.

Home PageContents Links

Spelling Checker

The English spelling checker (under Scripts in the Links) uses Vim's native syntax highlighting ability to make misspelled (English) words show up as an "Error" (usually white on a red background). Vim 7.0 introduced a built-in spelling checker with many features based on those engspchk provided; however, engspchk is still good for those of you still using earlier versions of vim. The Vim-based English spell checker also supports entering words that the cursor is on into a temporary or permanent dictionary and allows one to skip to the previous or subsequent spelling error (if any). It co-exists quite well with TeX, LaTeX, Html, and other such specialized text, and can be used to check the spelling inside comments in various programming languages.

Getting Started:

The English spelling checker now comes as a "tarball": gunzip the file <engspchk.tar.gz> and tar -oxvf engspchk.tar in the .vim or _vimfiles directory.

The English spelling checker is a plugin; it does a quick load and makes a map for \ec (actually the \ is <Leader> which can be changed; see :he mapleader). The dictionary isn't loaded until one types \ec. It also creates a menu item to load the spelling checker for gvim (the gui).

The custom user dictionary and optional Webster's 1913 dictionary is stored using the path specified by the vim variable g:cvimsyn, settable in the <.vimrc>. If that variable isn't set, then the CVIMSYN environment variable, if it exists, is used.

If you want to use the environment variable approach:

sh CVIMSYN="path";export CVIMSYN
csh setenv CVIMSYN "path"
ksh export CVIMSYN="path"
Windows 95,98 in <autoexec.bat>:
set CVIMSYN=..path..
Windows 2000,NT,etc Right click on <My Computer>
Choose <Properties>
Click <System Properties>
Click <Advanced> tab

Moving: For Vim versions 5.04 and later, the <engspchk.vim> file additionally provides two maps (\en and \ep) to move to the next and preceding spelling error, if any. I suggest you upgrade if you haven't already, because Vim's functions are powerful!

Custom Dictionary: Engspchk allows the user to temporarily save (\et) or to permanently save (\es) words the user uses but somehow isn't in Engspchk's dictionary. A temporary save only affects the current vim editing session; a permanent save writes the word to a custom user dictionary which is automatically loaded in the future.

Alternatives: For Vim version 6.0 and later, <engspchk.vim> provides the (\ea) map which brings up a one-line alternatives window for the word under the cursor. Move left and right with the full power of Vim, and when the cursor lies on the desired substitute word, a simple carriage return will cause replacement. You'll also need to have the agrep program to do this (there's a pre-compiled for Windows version available using this link). The first use of (\ea) takes longer than subsequent use because the script that gets invoked constructs a plain list of words from the engspchk file.

No Flashing: With Vim version 6.0y and later and starting with version 2.04 of engspchk no longer will Error highlighting flash on and off while you're typing. Thanks go to Chase Tingley (with emendations by Bram Moolenaar) who wrote the changes to Vim to make this possible.

More Words: Previously the <wb1913_engspchk.vim> file was provided separately, but it is now provided in the <engsphck.tar.gz> tarball. still optional if you'd rather not load it. Webster has provided an electronic copy of the words from its 1913 edition; those words that appear in that dictionary that don't appear in <engspchk.vim>'s dictionary itself are provided in the <wb1913_engsphck.vim> file. If the file appears in the directory specified by the g:cvimsyn variable (or by the CVIMSYN environment variable) then it is loaded automatically.

Languages other than English: There are now variants of <engspchk.vim> for Dutch, German, Hungarian, Polish, and Yiddish. Engspchk has been improved so that mostly all that's needed are the dictionaries themselves. I'd appreciate it if you could let me know where on the Web to find it so I can make a link on this page to it!

Since vim 7.0 and later now includes embedded spell checking, I've removed most of the spelling dictionaries. If someone is still interested, please send me an email (NdrOchip@ScampbellPfamily.AbizM - NOSPAM) and I'll send you a copy. Unfortunately, I'm limited on my webspace, and I needed the space! I have dictionaries for Dutch, French, German, Hungarian, Italian, Polish, Russian, and Spanish.

To see a screenshot, please click on this.

Home PageContents Links

Tag Generation

I have written my own tag generating program (get source for hdrtag here); although Exuberant Ctags is good, I know how to modify hdrtag to suit me. It contains tagging generation for C/C++, C/C++ header files, lex, yacc, TeX (cites and labels), vim scripts (functions and syntax), and Maple V.

Exuberant Ctags will no longer be distributed with vim as of v6.0i. I've provided a link to its home site here.

Home PageContents Links

Text Alignment

The alignment scripts (<Align.vim> and <AlignMaps.vim>) now supplant the older external filter approach. The new scripts, which include help and plentiful examples, provide:

See my DrChip's Alignment Tool for Vim page for links and examples. An alternative aligner is available from Gergely Kontra (Johannes Zellner used to have one available, but apparently his site has disappeared).

Home PageContents Links

Useful Maps

Home PageContents Links

Vim Functions, Plugs, and Stubs

VIM 7.0 USERS: BE SURE TO GET THE LATEST VIMBALL PLUGIN BEFORE ATTEMPTING TO USE SCRIPTS UPLOADED ON OR AFTER AUG 1, 2006

Various functions, plug-ins, and quick-insertion stubs follow alphabetically. There are several plugins that I post both here and at vim.sf.net. Scripts here are my most up-to-date ones and may be considered as alpha/beta releases; I tend to put the ones I'm updating/fixing here. After a bit of feedback, and a variable length of time (ie. whenever I get around to it), I will also post the scripts on vim.sf.net.

Most plugins here are provided in the vimball format; simply use vim name_of_plugin.vba.gz and follow the directions. Windows users may not have a gunzip utility; if you're a Windows user, you'll need to get one if you don't have one already.

Item Tool/Suite Free Website
7zip tool y try here
Winzip tool n try here
unxutils suite y try here
cygwin suite y try here
GnuWin32 suite y try here
MinGW suite y try here

Then type :so %; this runs the vimball utility and distributes the components of the plugins where they belong. It also enables help via vim's help facility for the plugin (ex. :help netrw).

I use three release states with my plugins:

Thus v1a is ASTRO-ONLY or possibly NOT RELEASED; v3 is RELEASED. In other words, I use the ASTRO-ONLY stage as an alpha/beta release, and NOT RELEASED as an alpha. This process is supposed to help get the bugs out before the plugin is potentially released to thousands.

If you have some feedback (problems or kudos!), please send an email to NdrOchip@ScampbellPfamily.AbizM (remove the embedded NOSPAM therein first, of course).

Home PageContents Links

Links

----
Category Description Link
Color Scheme DrChip's Colorscheme astronaut.tar.gz
----
Category Description Link
Elsewhere Vim Online Vim Online
Vim Download Site Vim Source
Vim Download Site Vim Source (Mercurial)
Vim FAQ Vim FAQ
Bill Joy's Original Vi Source Code Joy's Vi Source
Colorscheme Examples Vim Colorscheme Test
Gui Vim Cheat Sheet Vim Cheat Sheet and Tutorial
Gui Vim Cheat Sheet Vim Cheat Sheet
Less Home Page The Less home page
Postscript and PDF versions of Vim's User Documentation Vim Docs in PS/PDF
Vi Reference Vi Reference
Vim Book: by Oualline Vi Improved-VIM
Vim Book: by Oualline (not free) Wicked Cool Vim
Vim Book: by Swaroop A Byte of Vim
Vim's Author Bram Moolenaar's Vim Page
Vim and Eclipse Vimplugin
Vim's Latest Syntax Highlighting Files Syntax Highlighting Files
Vim's User Guide Vim's User Guide
Fellow Vim User (hypertext) Stefan Bittner
Fellow Vim User (vimail) Cesar A.R. Crusius
Fellow Vim User (jtags) Claudio Fleiner
Fellow Vim User (author of original vim home pages) Sven Guckes
Fellow Vim User (windows, binaries) Steve Hall
Fellow Vim User (tex latex) Luc Hermite
Fellow Vim User (bufexplorer, rcs) Jeff Lanzarotta
Fellow Vim User (vi v vim, outliner) Steve Litt
Fellow Vim User (tips) David Rayner
Fellow Vim User (xml) Tobias Reif
----
Category Description Link
Miscellaneous Pre-compiled executables Pre-Compiled Executables Upd 09/06/00
Early Unix History Unix History Lnkd 09/27/00
Vim Commands Short Vim List of Commands
Vim Functions, Plugs, and Stubs Vim Functions
Oleg Raisky's Vim 5 Reference Card Vim 5 Reference Card
Vim-LaTeX Suite Vim LaTeX Suite Lnkd 12/09/02
Vince Negri's ownsyntax/conceal patch Vince Negri's Ownsyntax/Conceal patch
----
Category Description Link
Scripts Alignment Upd 11/08/05
Matt Corks' Spelling Corrector Spelling Corrector Upd 12/01/00
----
Category Description Link
Tag Generation Exuberant Ctags
Tag Generation Hdrtag (C, C++, vim, tex)
----
Category Description Link
Syntax Amiga Script amiga.vim.gz
C shell csh.vim.gz
Dec's Control Language dcl.vim.gz
Elm Filter elmfilt.vim.gz
Unix's /etc/exports exports.vim.gz
Lex lex.vim.gz
Lisp lisp.vim.gz
Maple V maple.vim.gz
Rpcgen rpcgen.vim.gz
Sh Bash Ksh sh.vim.gz
Sendmail sm.vim.gz
Tags tags.vim.gz
LaTeX, TeX tex.vim.gz
Vim vim.vim.gz
Xmath xmath.vim.gz
Xxd xxd.vim.gz
Yacc yacc.vim.gz Astro-Only

Note:

An Astro-Only syntax file has not yet been sent to Bram Moolenaar but has been made available here for downloading and testing.


2 Tim 2:22 Now flee from youthful lusts, and pursue after righteousness, faith, love, and peace, with those who call on the Lord from a pure heart.


Home Contents

Previous Previous
The site you are viewing is a part of the Vi IMproved Editor Webring
Previous 5 Sites Previous Next Next 5 Sites Random Site List Sites
Next Next

Last Modified Oct 22, 2023 05:43:55 PM © 2012, Charles E Campbell