diff --git a/Default (Linux).sublime-keymap b/Default (Linux).sublime-keymap new file mode 100755 index 0000000..14276c8 --- /dev/null +++ b/Default (Linux).sublime-keymap @@ -0,0 +1,3 @@ +[ + { "keys": ["ctrl+shift+c"], "command": "remove_extra_right_spaces" } +] \ No newline at end of file diff --git a/Default (OSX).sublime-keymap b/Default (OSX).sublime-keymap new file mode 100755 index 0000000..ce4db77 --- /dev/null +++ b/Default (OSX).sublime-keymap @@ -0,0 +1,3 @@ +[ + { "keys": ["super+shift+c"], "command": "remove_extra_right_spaces" } +] diff --git a/Default (Windows).sublime-keymap b/Default (Windows).sublime-keymap new file mode 100755 index 0000000..d402486 --- /dev/null +++ b/Default (Windows).sublime-keymap @@ -0,0 +1,3 @@ +[ + { "keys": ["ctrl+shift+c"], "command": "remove_extra_right_spaces" } +] diff --git a/Default.sublime-commands b/Default.sublime-commands new file mode 100755 index 0000000..4f76e76 --- /dev/null +++ b/Default.sublime-commands @@ -0,0 +1,6 @@ +[ + { + "caption": "Remove extra right spaces", + "command": "remove_extra_right_spaces" + } +] \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..4ad99bd --- /dev/null +++ b/README.md @@ -0,0 +1,29 @@ +# Remove Extra Right Spaces + +This Sublime plugin removes extra right spaces from each line of your code. + +I hope you you find this plugin helpful. + +### Why? + + + +### Installation + +For manual installation, run the following script in the Sublime Text terminal ```(ctrl+`)``` which utilizes ```git clone```. + +```python +import os; path=sublime.packages_path(); (os.makedirs(path) if not os.path.exists(path) else None); window.run_command('exec', {'cmd': ['git', 'clone', 'https://github.com/pererinha/RemoveExtraRightSpaces', 'RemoveExtraRightSpaces'], 'working_dir': path}) +``` + +**It is currently working just for Sublime 3** + +### Usage +* On Mac **Command + Shift + C** +* On Windows or Linux **Ctrl + Shift + C** + +Or + +**Ctrl + Shift + P** and search for *“Remove extra right spaces”* + + diff --git a/messages.json b/messages.json new file mode 100644 index 0000000..2035aca --- /dev/null +++ b/messages.json @@ -0,0 +1,3 @@ +{ + "install": "messages/install.txt" +} \ No newline at end of file diff --git a/messages/1.txt b/messages/1.txt new file mode 100644 index 0000000..741f617 --- /dev/null +++ b/messages/1.txt @@ -0,0 +1,2 @@ +This is a beta release. +- Not tested on Linux, Windows. \ No newline at end of file diff --git a/messages/install.txt b/messages/install.txt new file mode 100644 index 0000000..7ba132b --- /dev/null +++ b/messages/install.txt @@ -0,0 +1,7 @@ +Thanks for installing the Remove Extra Right Spaces plugin. + +This plugin removes extra right spaces from each line of your code. + +I hope you you find this plugin helpful. + +Github page https://github.com/pererinha/RemoveExtraRightSpaces. \ No newline at end of file diff --git a/remove_right_spaces.py b/remove_right_spaces.py new file mode 100644 index 0000000..34ef625 --- /dev/null +++ b/remove_right_spaces.py @@ -0,0 +1,13 @@ +import sublime, sublime_plugin + +class RemoveExtraRightSpacesCommand(sublime_plugin.TextCommand): + def run(self, edit): + # I have no idea why the self.view is not returning the region correctly + view = self.view.window().active_view() + region = sublime.Region(0, min(view.size(), 2**14)) + content = view.substr(region) + new_content = '' + for line in content.split( '\n' ): + new_content += line.rstrip() + '\n' + view.replace(edit, region, new_content) +