At the end of The Structure of a Vim Plugin, we created our main plugin directory, mpc. This is where we’ll be putting the different directories in which Vim looks for VimL source files.
Under mpc, create the plugin directory and then create a file under it called mpc.vim. It should look like this:
plugin/mpc/plugin/mpc.vim | |
| function! OpenMPC() |
| let cmd = "mpc --format '%title% (%artist%)' current" |
| echomsg system(cmd)[:-2] |
| endfunction |
Because we appended the plugin directory to our runtimepath, Vim will load it automatically the next time we start it up. For now, though, save the file and then source it:
| :source % |
Now Vim should have OpenMPC ready to go. Make sure that mpc is running and then, from the Vim command line, run this:
| :call OpenMPC() |
As you can see in the following figure, Vim will display a message containing the track that mpc is playing.
18.226.165.247