vim

Vim a la TextMate

Alex Young posted “Vim for TextMate fans” a couple of years back, in which he ponders how to get the best of both worlds:

I’ve used vim a lot over the years, mainly because I spent a long time using Linux and it was there so I used it. The choice was obvious: vim or vi were on almost every machine I had access to, and worked excellently both locally and remotely. Once I’d learnt the basics I was set, I knew enough to get my work done.

Then I found TextMate for Mac OS. The immediacy of TextMate made it easy to get started with, and it has many excellent features. The problem is, I’m not always using a Mac. But you know who’ll follow me around to every platform I use? Good old vim! So I started thinking, how could I make vim feel more like TextMate?

Check out his screencast for more.

Using vim as a personal wiki

Abhijit Nadgouda over at iface thoughts describes a method of using vim as a simple wiki system, utilizing its built-in “tags” capability.

One thing I have learnt from experience is that the tool to collect and organize our information must be easily available and easy to use. And that is where vim scores higher than any other tool to build a wiki.[…]

Nowadays I use the vim as a combination of wiki and outliner to record my ideas and thoughts, documentation, tasks and even contacts.

Looks very easy to set up and use — I think I’ll give it a try.

A command line ebook reader

I was casting around for a replacement for the excellent Tofu screen text reader for Mac, due to some encoding issues. Always wont to explore the command-line options, I turned first to the ubiquitous less pager, available on pretty much every unix-alike system out there.

The only real drawback to less is its apparent inability to wrap long lines at spaces rather than chopping words in the middle and sans hyphenation. This isn’t a problem on hard-return files like a Project Gutenberg ebook, but makes for difficult reading otherwise. (The opposite is the case for Tofu, which requires a bit of manual column widening to compensate for the hard returns.)

Doing a bit of poking around, I re-discovered the also-ubiquitous fmt command, which does word wrapping to a fare-thee-well, though doesn’t do paging.

Combining the two commands gives the best of both in classic Unix fashion:

fmt 1911EthanFrome.txt | less

You can also use options to enhance the experience. less -m will give you a prompt showing how far along you are in the file; see man less for others.

The pager recognizes vim movement keys, which I love. Plus you can hit the v key at any time to drop into vim, edit the file, and then return to less. Spiffy.

Of course, you could just use vim (or your favorite text editor), but I like the simplicity without the overhead. Unlike other options, less doesn’t read the entire file into memory before displaying it, a definite advantage on big documents.

Another Tip: If you’re in a Mac Terminal window, right click on a word or phrase to search for it in Google or Dictionary.

Bonus tangential tip: if you don’t care about downloading the text files but want to stick to reading Project Gutenberg files in the terminal, why not use lynx or ELinks?

screenshot of terminal window showing lynx web browser viewing the Edith Wharton novel Ethan Frome on Project Gutenberg

Vi Input Manager for Cocoa text fields

By Jason Corso. Updated earlier this year to work with Leopard.

Vi Input Manager

This bundle patches the Cocoa Text System to add a Vi-like command mode. After entering command-mode (typically, by hitting escape in Vi), ordinary Vi commands can be typed and the text field will be updated accordingly. Essentially, this add Vi command functionality (albeit a small subset) to any (and all) text editors that use the Cocoa text system; e.g., Safari, TeXShop, XCode, etc. Note, however, this does not work for other programs that do not use the Cocoa system.

Compiling Word War vi on Mac OS X

screenshot of word war vi running via X11 on Mac OS X

As mentioned in the previous post, Word War vi is a retro arcade game along the lines of Defender or Stargate, allowing you to play out the Emacs vs Vim wars in all their nostalgic glory. It’ll run on Mac OS X, but it takes a bit of preparation. Here’s what I did to get it running on Leopard (10.5.5); your mileage may vary on older OS versions. Also, I don’t have a joystick to test, so I am unsure if that will work or not.

  1. Download and unarchive wordwarvi
  2. First up, make sure you have XTools installed, which you’ll find on your Leopard install DVD. You’ll also need the X11.app found in your Applications/Utilities folder, but that is likely already there.
  3. Next, install MacPorts. This will make it very simple to install the next two packages.
  4. Once MacPorts is installed, go to the Terminal and type sudo port install libvorbis (you’ll need to enter your password).
  5. Repeat the process with sudo port install portaudio
  6. Lastly, we need to specify where a particular file is found on your system. Inside the wordwarvi folder, there are two text files to edit: ogg_to_pcm.c and wordwarvi.c

In both files, near the top, you’ll find a line that reads:

#include <malloc.h>

Change it to read:

#include <malloc/malloc.h>

And that’s all the preparatory steps. In the wordwarvi folder via the Terminal, type make. It will compile shortly, and then (assuming everything went well), you’ll only have to enter ./wordwarvi to play it via X11.app.

You might want to turn the volume down on your Mac to start with — the music was pretty loud on my system.

Thanks to Stephen Cameron for the great game!

Syndicate content