16 Feb 2002 shlomif   » (Master)

Vim Macro

Due to the fact that I could not find any decent editor outside KDE that behaves just like I wanted, I decided to try and make gvim into an xmms front-end. Which naturally meant adding two macros (one for playing a file and the other for enqueuing it) into my .vimrc file.

I knew Vim macros were basically a recording of all the commands needed to execute them. So, after consulting the vim help pages a bit I came up with a generic macro that did just that. This macro had a problem in which it was not resistant to shell's special characters.

I worked on two other revisions of the macro. In the third revision everything was fixed except for filenames that contain newlines (which are pretty rare as it is).

What I did was copy the line containing the filename into a register, duplicate it below, substitute all the single quotes with the sequence '\'', copy it into the register again. Then, I entered the command line :!xmms '$reg' on the shell, and afterwards deleted the extra line.

Guy Keren once said to me that one did not do real programming until he programs with Vi macros. So, perhaps this was a baby step in the direction of becoming a "real" programmer.

This macro looks like line noise, doesn't it? ;-)

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!