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 ...

Get The VimL Primer now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.