File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ variety of languages and technologies. These are things that don't really
77warrant a full blog post. These are mostly things I learn by pairing with
88smart people at [ Hashrocket] ( http://hashrocket.com/ ) .
99
10- _ 433 TILs and counting..._
10+ _ 434 TILs and counting..._
1111
1212---
1313
@@ -496,6 +496,7 @@ _433 TILs and counting..._
496496- [ Searching For Hex Digits] ( vim/searching-for-hex-digits.md )
497497- [ Set End Of Line Markers] ( vim/set-end-of-line-markers.md )
498498- [ Set Your Color Scheme] ( vim/set-your-color-scheme.md )
499+ - [ Setting Filetype With Modelines] ( vim/setting-filetype-with-modelines.md )
499500- [ Show All Syntax Highlighting Rules] ( vim/show-all-syntax-highlighting-rules.md )
500501- [ Split Different] ( vim/split-different.md )
501502- [ Splitting For New Files] ( vim/splitting-for-new-files.md )
Original file line number Diff line number Diff line change 1+ # Setting Filetype With Modelines
2+
3+ Vim and various plugins generally use known file extensions to determine the
4+ filetype of a file. This is important because it is how Vim decides which
5+ filetype-specific settings to enable, such as syntax highlighting.
6+
7+ If I am editing a file such as ` build.boot ` , Vim is not going to know that
8+ its filetype should be set to ` clojure ` . The ` build.boot ` file is full of
9+ clojure code though, so I'm losing out on syntax highlighting and so forth.
10+ I can settle for manually setting the filetype to clojure (e.g. `: set
11+ ft=clojure`) each time I open up the file.
12+
13+ Or I can use a modeline setting. By including a comment at the top or
14+ bottom of the file specifying the filetype setting, I can ensure that each
15+ time I go to edit the file, the appropriate filetype will be set.
16+
17+ That modeline comment will look something like:
18+
19+ ``` clojure
20+ ; vim: set ft=clojure:
21+ ```
22+
23+ See ` :h modeline ` for more details.
24+
25+ h/t Brian Dunn
You can’t perform that action at this time.
0 commit comments