Last active
March 30, 2018 23:45
-
-
Save sheeit/ad6eb1b406f3dee72a5c9f055064e94d to your computer and use it in GitHub Desktop.
Some regexes to convert some stuff from Python to Lua
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
The substitute following commands are made for Vim. | |
Convert function declarations (prototypes): | |
:%s/^def\(\s\)\(\s*[_A-Za-z][_A-Za-z0-9]*\s*([^)]*)\s*\)\s*:\s*$/function\1\2/g | |
Convert "for i in range(a, b):" to "for i = a, b": | |
:%s/\(for\s\+[_A-Za-z][_A-Za-z0-9]*\s\)\s*in\s*range\s*(\s*\([^)]\+\)\s*)\s*:\(.*\)$/\1= \2\3/g | |
Convert "True" and "False" to "true" and "false": | |
:%s/true|false/\L&\E/gi | |
Convert "None" to "nil": | |
%s/None/nil/g |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment