Adding Mappings

Back in Writing Text to a Buffer, you saw how we can call normal-mode commands from a script. Those are commands like we enter all the time while using Vim—dd to delete a line, j to move down a line, p to paste, and so forth.

We’ve been adding some helpful commands to our plugin, but before we get this out to an actual user, we’ll also want to add mappings to those commands, for something closer to the ultimate in ease of use. We want to be able to say something along the lines of, “Hit Ctrl-x to play the song.” Saying, “Run :PlaySong(3) Enter” doesn’t have quite the same ring to it, does it?

Some of these mappings are going to be usable in our plugin only—and they won’t just be specific to our plugin, but they’re only ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.