Vim set file type of current buffer

Vim buffer editing is a basic vim operation and it goes hand in hand with editing vim files. I’ve written this cheat sheet as a way of remembering some of these simple, powerful, everyday vim commands.

What is a vim buffer?

When your editing files in vim. Keep in mind that you’re editing the memory buffer of a file and not the actual file. This is just how vim works by default.

Open a new empty buffer

This will open a new empty buffer in a vertical split window.


Open a new empty buffer in a full tab without a split


Refresh the current buffer


Change buffer file type

It can be helpful to change the file type of the current buffer. For instance, if you have prettier installed and you have a lot of html mixed into a php file. You can use your html prettier in your php file by changing the file type from php to html.

Change the filetype to html

set ft=html

Check the current filetype

set ft?
This post is licensed under CC BY 4.0 by the author.

Comments powered by Disqus.