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

Writing Text to a Buffer

Let’s now expand OpenMPC to display the entire playlist from mpc. For now, we’ll have the function call mpc to get the playlist and then display that in a new split window. Modify the code to look like this:

plugin.1/mpc/plugin/mpc.vim
Line 1 
function​! OpenMPC()
let​ cmd = ​"mpc --format '%position% %artist% / %album% / %title%' playlist"
let​ playlist = ​split​(system(cmd), ​'\n'​)
new
for​ track in playlist
if​(playlist[0] == track)
execute ​"normal! I"​ . track
10 
else
call​ append(line(​'$'​), track)
endif
endfor
endfunction

And now let’s quickly go over this before we try it out.

On line 3 we define a List, playlist, to store the result of our mpc call. We ...

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