Skip to content

Instantly share code, notes, and snippets.

@Gerzer
Created June 20, 2014 20:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gerzer/47bc941a52119da636c0 to your computer and use it in GitHub Desktop.
Save Gerzer/47bc941a52119da636c0 to your computer and use it in GitHub Desktop.
Snakeyes.py
import editor
full_text = editor.get_text()
cursor = editor.get_selection()[1]
while True:
try:
if full_text[cursor - 3] + full_text[cursor - 2] + full_text[cursor - 1] == 'def':
editor.replace_text(cursor, cursor, ' func_name():')
editor.set_selection(cursor + 1, cursor + 10)
if full_text[cursor - 3] + full_text[cursor - 2] + full_text[cursor - 1] == 'ifc':
editor.replace_text(cursor, cursor, ' condition:')
editor.set_selection(cursor + 1, cursor + 10)
if full_text[cursor - 3] + full_text[cursor - 2] + full_text[cursor - 1] == 'wlt':
editor.replace_text(cursor - 2, cursor, 'hile i < num:')
editor.set_selection(cursor + 7, cursor + 10)
if full_text[cursor - 3] + full_text[cursor - 2] + full_text[cursor - 1] == 'fea':
editor.replace_text(cursor - 2, cursor, 'or entry in array:')
editor.set_selection(cursor + 10, cursor + 15)
break
except:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment