README
1===============
2Line Operations
3===============
4
5.. contents::
6
7About
8=====
9
10Line Operations is an assortment of simple line functions that can be
11applied to an open file, or selection.
12
13Features
14========
15
16* Remove Duplicate Lines, sorted
17* Remove Duplicate Lines, ordered
18* Remove Unique Lines
19* Keep Unique Lines
20* Remove Empty Lines
21* Remove Whitespace Lines
22* Remove Every Nth Line
23* Sort Lines Ascending
24* Sort Lines Descending
25
26Usage
27=====
28
29After the plugins has been installed successfully, load the plugin via
30Geany's plugin manager and a new menu item in the Tools menu will
31appear ("Tools" > "Line Operations"). Click on each menu item to apply
32the operation on whole file, or selection. See descriptions below to
33see operations for each menu item.
34
35Preferences
36-----------
37
38To enable preferences ("Tools" > "Plugin Manager"), check the checkbox to
39enable Line Operations, and with the item highlighted click "Preferences"
40on bottom of the "Plugin Manager" frame.
41
42**Use collation based string compare** - When this option is enabled it will
43compare strings using linguistically correct rules for the current locale
44(g_utf8_collate).
45
46When it is disabled it will compare strings based on numerical value of the
47characters (strcmp).
48
49This option is disabled by default.
50
51 Example: Sort order using **Use collation based string compare** enabled
52
53 ::
54
55 D U+0044 : LATIN CAPITAL LETTER D
56 d U+0064 : LATIN SMALL LETTER D
57 E U+0045 : LATIN CAPITAL LETTER E
58 e U+0065 : LATIN SMALL LETTER E
59 Ê U+00CA : LATIN CAPITAL LETTER E WITH CIRCUMFLEX
60 é U+00E9 : LATIN SMALL LETTER E WITH ACUTE
61 F U+0046 : LATIN CAPITAL LETTER F
62 f U+0066 : LATIN SMALL LETTER F
63
64 Note: all 'e' characters appear after any 'd' character and before any 'f'
65 character.
66
67 Example: Sort order **Use collation based string compare** disabled
68
69 ::
70
71 D U+0044 : LATIN CAPITAL LETTER D
72 E U+0045 : LATIN CAPITAL LETTER E
73 F U+0046 : LATIN CAPITAL LETTER F
74 d U+0064 : LATIN SMALL LETTER D
75 e U+0065 : LATIN SMALL LETTER E
76 f U+0066 : LATIN SMALL LETTER F
77 Ê U+00CA : LATIN CAPITAL LETTER E WITH CIRCUMFLEX
78 é U+00E9 : LATIN SMALL LETTER E WITH ACUTE
79
80 Note: all the 'e' characters do not appear together.
81
82
83Selection
84---------
85
86If a selection is made in the file, the line operation will be applied to the
87lines within the selection. The beginning of the selection will expand to the
88beginning of its line, and the end of the selection will expand to the end of
89its line. If the end of the selection is on col 0, that line will be included.
90
91Notes
92-----
93
94 * Line Operations will **not** make changes to a file until you save
95 the file.
96
97
98Operation Details
99=================
100
101Remove Duplicate Lines
102----------------------
103
104The first occurrence of each duplicate line will remain in the file.
105The **Sorted** option will sort the file and remove duplicate lines
106[fast on large files]. The **Ordered** option will keep the same order
107of lines [slow on large files].
108
109 Example: Suppose a file has the following lines. (#comments added for
110 clarity)
111
112 ::
113
114 Line 2
115 Line 1
116 Line 2 #removed
117 Line 3
118 Line 1 #removed
119 Line 2 #removed
120
121 The **Remove Duplicate Lines, sorted** will change the file into this:
122
123 ::
124
125 Line 1
126 Line 2
127 Line 3
128
129 The **Remove Duplicate Lines, ordered** will change the file into
130 this:
131
132 ::
133
134 Line 2
135 Line 1
136 Line 3
137
138
139
140Remove Unique Lines
141-------------------
142
143Removes all lines that appear only once.
144
145 Example: Suppose a file has the following lines. (#comments added for
146 clarity)
147
148 ::
149
150 Line 2
151 Line 1
152 Line 2
153 Line 3 #removed
154 Line 1
155 Line 2
156
157 The **Remove Unique Lines** will change the file into this:
158
159 ::
160
161 Line 2
162 Line 1
163 Line 2
164 Line 1
165 Line 2
166
167
168Keep Unique Lines
169-------------------
170
171Keep all lines that appear only once.
172
173 Example: Suppose a file has the following lines. (#comments added for
174 clarity)
175
176 ::
177
178 Line 4
179 Line 1 #removed
180 Line 2 #removed
181 Line 3
182 Line 1 #removed
183 Line 2 #removed
184
185 The **Keep Unique Lines** will change the file into this:
186
187 ::
188
189 Line 4
190 Line 3
191
192
193Remove Empty Lines
194------------------
195
196Removes all lines that only contain a newline character, and no other
197characters.
198
199 Example: Suppose a file has the following lines. (#comments, and
200 \\n newline characters added for clarity)
201
202 ::
203
204 Line 2\n
205 Line 1\n
206 \n #removed
207 \n #NOT removed (contains spaces)
208 Line 1\n
209 Line 2\n
210
211 The **Remove Empty Lines** will change the file into this:
212
213 ::
214
215 Line 2\n
216 Line 1\n
217 \n
218 Line 1\n
219 Line 2\n
220
221
222Remove Whitespace Lines
223-----------------------
224
225Removes all lines that have only whitespace characters.
226
227
228 Example: Suppose a file has the following lines. (#comments, and \\n
229 newline characters added for clarity)
230
231 ::
232
233 Line 2\n
234 Line 1\n
235 \n #removed
236 \n #removed (contains only whitespace chars)
237 \t \n #removed (contains only whitespace chars)
238 Line 1\n #NOT removed (contains non whitespace chars)
239 Line 2\n
240
241 The **Remove Whitespace Lines** will change the file into this:
242
243 ::
244
245 Line 2\n
246 Line 1\n
247 Line 1\n
248 Line 2\n
249
250Remove Every Nth Line
251---------------------
252
253The user can enter a number N. Every Nth line will be removed then.
254
255 Example: Suppose a file has the following lines and the user enters the
256 value 2 for N. (#comments added for clarity)
257
258 ::
259
260 Line 1
261 Line 2 #removed
262 Line 3
263 Line 4 #removed
264 Line 5
265
266 The **Remove Every Nth Line** (N=2) will change the file into this:
267
268 ::
269
270 Line 1
271 Line 3
272 Line 5
273
274Sort Lines
275----------
276
277Sorts lines ascending or descending based on ASCII values
278(lexicographic sort).
279
280
281 Example: Suppose a file has the following lines.
282
283 ::
284
285 line 1
286 line 2
287 line
288 line 3
289 line
290
291 The **Sort Lines Ascending** will change the file into this:
292
293 ::
294
295 line
296 line
297 line 1
298 line 2
299 line 3
300
301
302 The **Sort Lines Descending** will change the file into this:
303
304 ::
305
306 line 3
307 line 2
308 line 1
309 line
310 line
311
312
313License
314=======
315
316The Line Operations plugin is distributed under the terms of the GNU
317General Public License as published by the Free Software Foundation;
318either version 2 of the License, or (at your option) any later version.
319A copy of this license can be found in the file COPYING included with
320the source code of this program.
321
322Ideas, questions, patches and bug reports
323=========================================
324
325Please direct all questions, bug reports and patches to the plugin
326author using the email address listed below or to the Geany mailing
327list to get some help from other Geany users, or report them at
328https://github.com/geany/geany-plugins/issues.
329