1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-09 10:08:01 +00:00

Add Setting Filetype With Modelines as a vim til

This commit is contained in:
jbranchaud
2016-06-17 22:43:07 -05:00
parent 930432606c
commit ae8f05386d
2 changed files with 27 additions and 1 deletions

View File

@@ -0,0 +1,25 @@
# Setting Filetype With Modelines
Vim and various plugins generally use known file extensions to determine the
filetype of a file. This is important because it is how Vim decides which
filetype-specific settings to enable, such as syntax highlighting.
If I am editing a file such as `build.boot`, Vim is not going to know that
its filetype should be set to `clojure`. The `build.boot` file is full of
clojure code though, so I'm losing out on syntax highlighting and so forth.
I can settle for manually setting the filetype to clojure (e.g. `:set
ft=clojure`) each time I open up the file.
Or I can use a modeline setting. By including a comment at the top or
bottom of the file specifying the filetype setting, I can ensure that each
time I go to edit the file, the appropriate filetype will be set.
That modeline comment will look something like:
```clojure
; vim: set ft=clojure:
```
See `:h modeline` for more details.
h/t Brian Dunn