-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from ilyakam/release/1.0.0
chore(*): release version 1.0.0
- Loading branch information
Showing
10 changed files
with
165 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Unifying editor configurations for all developers: | ||
# For details see http://editorconfig.org/ | ||
|
||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
indent_size = 2 | ||
indent_style = space | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.DS_Store | ||
*.pyc |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Change Log | ||
All notable changes to this project will be documented in this file. | ||
This project adheres to [Semantic Versioning](http://semver.org/). | ||
|
||
## [1.0.0] - 2018-04-21 | ||
### Added: | ||
- Ability to remove duplicate lines from the entire file | ||
- Ability to remove all lines that match the selection | ||
- Default keyboard shortcut: <kbd>shift</kbd><kbd>F5</kbd> | ||
- Documentation: `README`, `CONTRIBUTING`, and `LICENSE` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Contributing | ||
|
||
Thank you for your interest in contributing to this project! Here's what you need to know to get started. | ||
|
||
1. [Maintainers](#maintainers) | ||
1. [Order of Operations](#order-of-operations) | ||
1. [Getting Started](#getting-started) | ||
1. [Commit Guidelines](#commit-guidelines) | ||
|
||
## Maintainers | ||
|
||
This project is currently being maintained by: | ||
|
||
* Ilya Kaminsky ([@ilyakam](https://github.com/ilyakam/)) | ||
|
||
## Order of Operations | ||
|
||
1. [Create a new issue](https://github.com/ilyakam/RemoveDuplicateLines/issues/new) | ||
1. Fork the repo | ||
1. Write code and thoroughly test it | ||
1. [Submit a pull request](https://github.com/ilyakam/RemoveDuplicateLines/compare) against `develop` | ||
1. Communicate in a timely manner while the PR is open | ||
|
||
## Getting Started | ||
1. Clone this repo (`~/code` is assumed) | ||
```sh | ||
cd ~/code | ||
git clone [email protected]:ilyakam/RemoveDuplicateLines.git | ||
``` | ||
1. Create an alias in your [Sublime Text's Packages folder](https://forum.sublimetext.com/t/9484) (macOS is assumed) | ||
```sh | ||
cd ~/Library/Application\ Support/Sublime\ Text\ 3/Packages/ | ||
ln -s ~/code/RemoveDuplicateLines ./ | ||
``` | ||
|
||
## Commit Guidelines | ||
|
||
Please follow the commit guidelines created by the AngularJS team. The latest version can be found [here](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#commits). |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[ | ||
{"keys": ["shift+f5"], "command": "remove_duplicate_lines"} | ||
] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[ | ||
{"keys": ["shift+f5"], "command": "remove_duplicate_lines"} | ||
] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[ | ||
{"keys": ["shift+f5"], "command": "remove_duplicate_lines"} | ||
] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# License | ||
|
||
The MIT License (MIT) | ||
|
||
Copyright (c) 2018 Ilya Kaminsky | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# RemoveDuplicateLines - A Sublime Text Plugin | ||
|
||
A plugin for [Sublime Text](http://www.sublimetext.com/) that allows you to remove duplicate lines from the file. | ||
|
||
## Usage | ||
|
||
<kbd>shift</kbd><kbd>F5</kbd> on all platforms. You might also need to hold <kbd>(fn)</kbd> depending on your OS/BIOS configuration. | ||
|
||
There are two ways to use this plugin: | ||
|
||
### Without a selection | ||
|
||
This removes all duplicate lines, leaving each line to be unique to the entire file. | ||
|
||
| Before | After | | ||
| ------ | ----- | | ||
|  |  | | ||
|
||
### With a selection | ||
|
||
This removes all lines from the file that match the selection. | ||
|
||
| Before | After | | ||
| ------ | ----- | | ||
|  |  | ||
|
||
## Changelog | ||
|
||
See [CHANGELOG.md](./CHANGELOG.md) | ||
|
||
## Contributing | ||
|
||
See [CONTRIBUTING.md](./CONTRIBUTING.md) | ||
|
||
## License | ||
|
||
See [LICENSE.md](./LICENSE.md) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import sublime | ||
import sublime_plugin | ||
|
||
class RemoveDuplicateLinesCommand(sublime_plugin.TextCommand): | ||
def run(self, edit): | ||
""" | ||
Removes duplicate lines so that each line contains a unique string | ||
If a line is selected, it removes duplicate occurrences ONLY of the selection | ||
""" | ||
|
||
def delete_lines(needle, lines): | ||
""" | ||
Marks lines for deletion one by one and deletes them all at once | ||
""" | ||
needle_contents = self.view.substr(needle) | ||
needle_size = needle.size() | ||
|
||
for line in lines: | ||
# Improve performance by comparing sizes before contents: | ||
if (needle_size == line.size() and | ||
needle_contents == self.view.substr(line)): | ||
|
||
# Mark line for deletion by adding it to the selection: | ||
self.view.sel().add(self.view.full_line(line)) | ||
|
||
# Avoid deleting the existing selection, if any | ||
self.view.sel().subtract(needle) | ||
|
||
# Delete all selections in reverse order to preserve the cursor position: | ||
for deletion_selection in reversed(self.view.sel()): | ||
self.view.replace(edit, deletion_selection, "") | ||
|
||
self.view.sel().clear() | ||
|
||
for region in self.view.sel(): | ||
# Select the entire file: | ||
lines = self.view.lines(sublime.Region(0, self.view.size())) | ||
|
||
if region.empty(): | ||
while len(lines) > 0: | ||
delete_lines(lines.pop(0), lines) | ||
|
||
else: | ||
delete_lines(region, lines) |