Created
July 19, 2011 00:27
-
-
Save bgreenlee/1091026 to your computer and use it in GitHub Desktop.
Sublime Text 2 plugin to strip trailing whitespace #python #sublimetext
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
import sublime_plugin | |
class StripTrailingWhitespaceCommand(sublime_plugin.TextCommand): | |
""" | |
Strip whitespace from the end of each line in the file. | |
""" | |
def run(self, edit): | |
trailing_white_space = self.view.find_all("[\t ]+$") | |
trailing_white_space.reverse() | |
for r in trailing_white_space: | |
self.view.erase(edit, r) |
Cool simple Sublime plugin! Why did you reverse the pattern matches in line 9?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To bind to a key sequence, select Preferences -> User Key Bindings and add: