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

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:

 
filetype​=mpdv

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:

filetype/mpc/ftplugin/mpdv.vim
 
set​ ​buftype​=nofile

The buftype

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