The Built-in Buffer Functions

When we finished with OpenMPC at the end of Chapter 2, A Real Live Plugin, we opened a window with the :new, which simply opens a new window and immediately moves to it. When we run this command, the window we open displays the buffer name [No Name], because it has no name—we’ve opened a new window to nothing.

In our updated OpenMPC, if we’ve already opened a window, we reuse it. The :new command now opens a named buffer in the new window, and from then on we can refer to that window by the name of the buffer to which it’s opened.

So here’s our new process for opening the playlist window. We start by checking for a buffer with the buffer name we’ve devised:

 
function​! OpenMPC()
 
if​(bufexists(​'mpc.mpdv' ...

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.