Improved vim modeline detection

TLDR: This greatly increases the flexibility of vim modeline detection
to manually set the language of a file.

In vim there are two forms of modelines:

[text]{white}{vi:|vim:|ex:}[white]{options}
examples: 'vim: syntax=perl', 'ex: filetype=ruby'

-and-

[text]{white}{vi:|vim:|Vim:|ex:}[white]se[t] {options}:[text]
examples: 'vim set syntax=perl:', 'Vim: se ft=ruby:'

As you can see, there are many combinations. These changes should allow
most combinations to be used. The two most important additions are the
use of the keyword 'syntax', as well as the addition of the first form
(you now no longer need to use the keyword 'set' with a colon at the end).
The use of first form with 'syntax' is very, very common across GitHub:

https://github.com/search?l=ruby&q=vim%3A+syntax%3D&ref=searchresults&type=Code&utf8=%E2%9C%93
This commit is contained in:
chrisarcand
2016-01-16 07:50:55 -05:00
parent 0c071990cb
commit d87fad649c
9 changed files with 41 additions and 3 deletions

View File

@@ -59,6 +59,9 @@ Alternatively, you can use Vim or Emacs style modelines to set the language for
##### Vim
```
# Some examples of various styles:
vim: syntax=java
vim: set syntax=ruby:
vim: set filetype=prolog:
vim: set ft=cpp:
```