Skip to content

Instantly share code, notes, and snippets.

@IvanWooll
Created May 23, 2020 13:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IvanWooll/1b3cbfe4abe4ad5340a04210be58e6aa to your computer and use it in GitHub Desktop.
Save IvanWooll/1b3cbfe4abe4ad5340a04210be58e6aa to your computer and use it in GitHub Desktop.
import sublime, sublime_plugin, re, string
class KdcformatCommand(sublime_plugin.TextCommand):
def run(self, edit):
for region in self.view.sel():
if not region.empty():
s = self.view.substr(region)
news = s.replace('[', '[\n\t')
news = news.replace('(','(\n\t\t')
news = news.replace(', ',',\n\t\t')
news = news.replace(']','\n]')
news = news.replace(')','\n\t\t)')
news = news.replace('),','),\n')
self.view.replace(edit, region, news)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment