Last active
August 29, 2015 14:14
-
-
Save bkeepers/b252627ef2c3458f49a7 to your computer and use it in GitHub Desktop.
Regular expression for vim and emacs modelines.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/ | |
(?: | |
(-\*- \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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; -*-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