Making Filetype-Specific Changes

We now have our filetype ready to go. Run the OpenMPC function again:

:​call​ OpenMPC()

And now for a handy trick: when we call the :set command on an option and include the ? flag instead of a value, :set echoes the option’s current value. Try this now with filetype:

:​set​ ​filetype​?

You should see Vim report our filetype:


With a filetype, we now can set buffer-specific options, using a file in that other filetype-related directory: ftplugin. Create that directory if it doesn’t exist yet.

Within ftplugin, create the file mpdv.vim. We won’t be doing too much in this file just yet—for now, just give it this line:

set​ ​buftype​=nofile

The buftype

Get The VimL Primer now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.