Contents
About
Line Operations is an assortment of simple line functions that can be applied to an open file.
Features
- Remove Duplicate Lines, sorted
- Remove Duplicate Lines, ordered
- Remove Unique Lines
- Remove Empty Lines
- Remove Whitespace Lines
- Sort Lines Ascending
- Sort Lines Descending
Usage
After the plugins has been installed successfully, load the plugin via Geany's plugin manager and a new menu item in the Tools menu will appear. Click on each menu item to apply the operation on whole file. See descriptions below to see operations for each menu item.
Notes
- Line Operations will not make changes to a file until you save the file.
Operation Details
Remove Duplicate Lines
The first occurrence of each duplicate line will remain in the file. The Sorted option will sort the file and remove duplicate lines [fast on large files]. The Ordered option will keep the same order of lines [slow on large files].
Example: Suppose a file has the following lines. (#comments added for clarity)
Line 2 Line 1 Line 2 #removed Line 3 Line 1 #removed Line 2 #removedThe Remove Duplicate Lines, sorted will change the file into this:
Line 1 Line 2 Line 3The Remove Duplicate Lines, ordered will change the file into this:
Line 2 Line 1 Line 3
Remove Unique Lines
Removes all lines that appear only once.
Example: Suppose a file has the following lines. (#comments added for clarity)
Line 2 Line 1 Line 2 Line 3 #removed Line 1 Line 2The Remove Unique Lines will change the file into this:
Line 2 Line 1 Line 2 Line 1 Line 2
Remove Empty Lines
Removes all lines that only contain a newline character, and no other characters.
Example: Suppose a file has the following lines. (#comments, and \n newline characters added for clarity)
Line 2\n Line 1\n \n #removed \n #NOT removed (contains spaces) Line 1\n Line 2\nThe Remove Empty Lines will change the file into this:
Line 2\n Line 1\n \n Line 1\n Line 2\n
Remove Whitespace Lines
Removes all lines that have only whitespace characters.
Example: Suppose a file has the following lines. (#comments, and \n newline characters added for clarity)
Line 2\n Line 1\n \n #removed \n #removed (contains only whitespace chars) \t \n #removed (contains only whitespace chars) Line 1\n #NOT removed (contains non whitespace chars) Line 2\nThe Remove Whitespace Lines will change the file into this:
Line 2\n Line 1\n Line 1\n Line 2\n
Sort Lines
Sorts lines ascending or descending based on ASCII values (lexicographic sort).
Example: Suppose a file has the following lines.
line 1 line 2 line line 3 lineThe Sort Lines Ascending will change the file into this:
line line line 1 line 2 line 3The Sort Lines Descending will change the file into this:
line 3 line 2 line 1 line line
License
The Line Operations plugin is distributed under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. A copy of this license can be found in the file COPYING included with the source code of this program.
Ideas, questions, patches and bug reports
Please direct all questions, bug reports and patches to the plugin author using the email address listed below or to the Geany mailing list to get some help from other Geany users, or report them at https://github.com/geany/geany-plugins/issues.