Skip to content

Instantly share code, notes, and snippets.

@cluke009
Created August 22, 2012 14:13
Show Gist options
  • Save cluke009/3426023 to your computer and use it in GitHub Desktop.
Save cluke009/3426023 to your computer and use it in GitHub Desktop.
Sublime Text 2 plugin that converts file to unix line endings and tabs to space on save
import sublime, sublime_plugin
# http://www.butlerpc.net/blog/2012/07/sublime-text-2-plugin-to-convert-tabs-to-spaces-on-save/
# tabs to spaces
# https://github.com/SublimeText/LineEndings/blob/master/LineEndings.py
# for line ending conversion code
class ConvertTabsToSpaces(sublime_plugin.EventListener):
def on_pre_save(self, view):
edit = view.begin_edit()
view.run_command('expand_tabs', {"set_translate_tabs": True})
view.run_command('set_line_ending', {"type":"unix"})
view.end_edit(edit)
#sublime.message_dialog("Converted endings.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment