Skip to content

Instantly share code, notes, and snippets.

@cclauss
Created April 22, 2013 14:55
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cclauss/5435710 to your computer and use it in GitHub Desktop.
Save cclauss/5435710 to your computer and use it in GitHub Desktop.
Simple Pythonista utility script that you need to put this Pythonista Actions menu. It goes though the script currently open in the Pythonista Editor, converting all tab characters ('\t') into four space characters.
# replace ALL tab characters with four spaces
import editor, sys
theText = editor.get_text()
theCount = theText.count('\t')
if not theText.count('\t'):
print('no tabs found.')
sys.exit()
theLength = len(theText)
theText = theText.splitlines()
#theSelection = editor.get_selection()
for i in range(len(theText)):
theText[i] = theText[i].replace('\t', ' ')
editor.replace_text(0, theLength, '\n'.join(theText))
#editor.set_selection(theSelection[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment