Regular expression for vim and emacs modelines.
/ | |
(?: | |
(-\*- \s* (?:mode:)? \s*) | # $1: Emacs | |
(\/\* \s* vim: \s* set \s* (?:ft|filetype)=) # $2: Vim | |
) | |
(\w+) # $3: language | |
(?: | |
(?(1) # If $1 matched... | |
;?\s* -\*- | # then close Emacs syntax | |
: \s* \*\/ # otherwise close Vim syntax | |
) | |
) | |
/x |
; -*-php-*- | |
# ; -*- mode: php;-*- | |
# /* vim: set filetype=perl: */ | |
# /* vim: set ft=perl: */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment