Skip to content

Instantly share code, notes, and snippets.

@bkeepers

bkeepers/modelines.rb

Last active Aug 29, 2015
Embed
What would you like to do?
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
You can’t perform that action at this time.