diff --git a/README.md b/README.md index 12e5697..fef1a62 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ variety of languages and technologies. These are things that don't really warrant a full blog post. These are mostly things I learn by pairing with smart people at [Hashrocket](http://hashrocket.com/). -_433 TILs and counting..._ +_434 TILs and counting..._ --- @@ -496,6 +496,7 @@ _433 TILs and counting..._ - [Searching For Hex Digits](vim/searching-for-hex-digits.md) - [Set End Of Line Markers](vim/set-end-of-line-markers.md) - [Set Your Color Scheme](vim/set-your-color-scheme.md) +- [Setting Filetype With Modelines](vim/setting-filetype-with-modelines.md) - [Show All Syntax Highlighting Rules](vim/show-all-syntax-highlighting-rules.md) - [Split Different](vim/split-different.md) - [Splitting For New Files](vim/splitting-for-new-files.md) diff --git a/vim/setting-filetype-with-modelines.md b/vim/setting-filetype-with-modelines.md new file mode 100644 index 0000000..8e33f21 --- /dev/null +++ b/vim/setting-filetype-with-modelines.md @@ -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