Chapter 6Commands and Mappings

We’ve been using Vim commands throughout this book. In fact, most of the code we’ve been writing in our script files could be executed on Vim’s command line as a long series of commands. But as with functions, we can write our own commands with VimL—they’re called user commands.

We can also map keys and key combinations. You might have mapped or remapped Vim functions before in your .vimrc file. Vim gives us a lot of choices for how we map keys—particularly when we include the mappings as part of our plugin—and even lets us give users an easy way to reconfigure those mappings to taste.

In this chapter we’ll start by writing commands that call our mpc functions. Then we’ll see how we can map keys to call our ...

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.