Vim ( Vi Improved )

[ What is Vim ] [ Useful Stuff ] [ Stuff I've coded for Vim ] [ Macros/Functions] [ hjkl everywhere ]

What is Vim?

Vim is the editor I use both at home and at work to edit and maneuver text files, scripts, code, and just about anything else. I even write my HTML pages using Vim including the one you're reading. If you're unfamiliar with Vi check out the Vi Lovers page for some excellent anti-Emacs propoganda ;). Click the thumbnail for a larger image showing my desktop running gvim.

For starters Vi's big selling point to me was the ability to move around a file without moving from the "home row". It's much more than that however...

Vim has some cool features that are not found in other editors. These are a few of it's main features (as of version 6.0ap the first 6.0 BETA) type :h version6.txt to see all that's changed since 5.7/8:

  • Vertically split windows ( a very welcomed feature! ).
  • Diff mode. You can now use use vim to do graphical diffs of files.
  • Folding. You can hide functions, comments, or arbitrary segments of your file to help readability etc.
  • A new file browser script ala dired in Emacs. Very nice. I would love to see a 2 pane version like the venerable Norton/Midnight Commander clones.
  • You can now communicate between Vims. This is a very cool feature allowing you to, for instance, use one instance of vim to edit files. But that's just the tip of the iceberg of what this feature can be used for.

These features have been in Vim since versions previous to 6.

  • Syntax hilighting for many, many languages, and it's seemingly infinitely comfigurable. No compiling DLLs either.
  • Vim has been ported to numerous operating systems including Amiga DOS, MS-DOS, MS-Windows 95/98/NT (Win 3.1 coming), Atari MiNT, Macintosh, BeOS, VMS, RISC OS, OS/2 and almost all flavours of UNIX. Where are those 8-bit ports? :)
  • "Almost" Vi compatible. From most accounts it's compatability is pretty high. Vim is my first experience with Vi so I know no better!
  • The source code is freely available so if you want, you can work on it or add some functionality to it.
  • A powerful built in scripting language, and also support for Perl, TCL, Ruby, and Python.

I could go on and on... try it for yourself and see.

Stuff I found useful to use with(in) Vim

VisVim

VisVim add-in available for VC++. When opening a file now jumps to the spot in Vim. Has lots of other features but that's all I use it for, loading on demand.

OpenWithVim / SendToVim

These excellent utilities help to integrate Vim into the windows environment just a little better. OpenWithVim allows directing any file to *one* instance of Vim using OLE. SendToVim allows sending any vim commands to the running instance. Very cool! Both programs are part of the extra zip included with the distribution. The 6.0 betas now have this functionality built in for all platforms using arguments to vim (+clientserver).

Cygwin

Cygwin has ported most if not all of the Unix command line utilites for Win32. Interoperates very well with Vim as well as there being a cygwin port of Vim that groks the /cygdrive etc notations.

Stuff I've written to use with(in) Vim

VC++ additions

For those who use Visual C++ and edit with Vim this might interest you. I wanted to be able to run VC++ commands from within Vim. VisVim is a great VC++ add-in but it currently only handles 1 way communications: From VC++ to Vim .

If you compile Vim for the Win32 platform yourself, add the two files that are located here, and add them to the project. The header file has instructions on how to add this functionality within Vim. Hopefully this will be added as a compile option into the main Vim code base but I want to do further testing and add a little more functionality before submitting it. NOTE: This code is not a stellar example of how to use ATL, feel free to clean it up, it was also created around the time of 5.7 so it's probably a little different now.

Features ( not all are implemented yet ):

  • Can execute any command that is listed in the Tools->Customize->Keyboard property page. The command for this is vc.
    For example on the command/ex mode line type ":vc DebugGo" and you'll start debugging. If VC++ is not running an instance will start.
  • Will open a file in VC++ from within Vim. This allows the two way connection with VisVim providing the other direction.
  • Set a breakpoint in VC++ from within Vim. Give the file and line number and a breakpoint will be set there. I'm not sure how useful seeing what breakpoints are set from within Vim would be , and I imagine synchronizing them will involve changes to VisVim. I'm be happy just to be able to set a breakpoint from within and kick off the debugger.

  Download!

vimsh : Terminal/Shell buffer for vim

Works if you have a python enabled [g]vim and the platform you run on supports pty or pipes. Most Unix variants should work fine as well as Windows. This is an interactive shell buffer, not using tricks like !r . It will maintain, for example, the process environment because the shell process is the same. Click here for a screenshot of it in action. Note that the password entry part of the ftp session used the vim input_secret so that the password is not seen in the buffer/history etc.

Click here to see a screenshot under Linux.

Click here to see a screenshot under Windows.

Unix tarball:      Download!

Windows zip:     Download!

Macros and functions I find useful

The following link has my ~/.vim directory which has some helpful things for using vim I've accumulated over the years, including:

  • A grep script that works with findstr.exe and grep. The script has many options and will put the output of the search into a vim window. There is also one that provides the same functionality for Unix. This is a modified version of one that I ran across somewhere on the net. Ron Aaron was the original author and I'm not sure who is maintaining the original now.
  • Script for toggling C-C++/H files
  • Many useful macros/highlight regexes for dealing with .c,.cpp, perl, python, html, and shell script files.
  • An regex alignement macro that will clean up stuff like

    foo = bar;

    variable = 2;

    and align the '=' on each line

  • Much more, from many years of tweaking my favorite editor!
  Download!

Using hjkl keys everywhere!

I really like using the hjkl keys for movement and have patches for a few window managers/libraries/etc to use them for menu traversal, and moving and resizing windows. Go to my programming page to grab them. I currently have patches for afterstep, kde (qt menus, and kwin size/move). I now use fvwm2 which supports using hjkl out of the box so I no longer need these patches.

This site is a member of WebRing.
To browse visit Here.