O'Reilly logo

The VimL Primer by Benjamin Klein

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Specifying a New Syntax

Let’s get back to mpc#GetPlaylist now. We have an odd problem when coming up with a syntax for our playlist’s text. We need to separate titles and names, but we also need to be able to tell which is which. To do that, we’ll need to use more specific delimiting characters—titles and names can contain the space character, so we can’t use that.

Here’s our solution: For each track in the playlist, we’ll append a couple of characters of the item type’s name, along with our trusty @ character, to the beginning and ending of each item. If mpc gives us Jim Cole as the artist our playlist will include that as follows:

 
@arJim Colear@

We’ll add two new functions to do this; one will encode track items in this syntax, and one ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required