Post

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.

1
:new

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

1
:enew

Refresh the current buffer

1
:e

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

1
set ft=html

Check the current filetype

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

Comments powered by Disqus.