Lines tools
This section may contain incomplete, premature, or mistaken information, prone to change without notice.
Indent Unindent Quote Unquote Shift Left Close Unclose Shift Right
Trim Tail Spaces (Ctrl+Shift+A)
Removes all white-spaces
from the end of each line
of the selection.
One little, two little, three little Indians. |
One little, two little, three little Indians. |
See also Unclose Lines, Shift Lines Right and Trim Empty Lines tools.
See also Unindent Lines tool. Trim Empty
Tabify (Ctrl+Shift+O)
Tabifies the indentation of the selection by replacing groups of leading white-spaces
with Tabs on each line
according to the current Tab Size setting. See chapter Edit page of the Settings dialog for more details.
If Tabs and Spaces are mixed together on the beginning of a line, the total visual white-space
extent is calculated first, and only then Tabs (and Spaces) are used to fill the space of the original indentation. Note that Tabs always take precedence over Spaces while filling the indentation, i.e. Spaces are used only if necessary (where another Tab would overflow the original extent of the indentation).
Note: Using this tool should not generate any visible changes to the indentation, when used with a fixed-width font. However, some proportional fonts do not use the average character width for Spaces, thus Tabs may seem to be longer than a set of Spaces. This is a visual inconvenience only and should not be considered incorrect.
Note: This tool does not modify any other white-spaces
than the leading ones.
See also Untabify tool.
Untabify (Alt+Ctrl+O)
Untabifies the indentation of the selection by replacing leading Tabs with Spaces on each line
according to the current Tab Size setting. See chapter Edit page of the Settings dialog for more details.
If Tabs and Spaces are mixed together on the beginning of a line, the total visual white-space
extent is calculated first, and only then Spaces are used to fill the space of the original indentation.
Note: Using this tool should not generate any visible changes to the indentation, when used with a fixed-width font. However, some proportional fonts do not use the average character width for Spaces, thus Tabs may seem to be longer than a set of Spaces. This is a visual inconvenience only and should not be considered incorrect.
Note: This tool does not modify any other white-spaces
than the leading ones.
See also Tabify tool. Remove Empty Collapse Empty Unique
Find duplicates.. (Alt+Ctrl+X)
Searches the selection for duplicate lines
. Then either counts and/or removes duplicates, or removes unique lines, depending on following options and choices:
- All lines (remove duplicates) - Removes all duplicate
lines
, keeping exactly one instance of each original line. The order of resultinglines
remains unchanged and from each two equal lines, the second one is removed. This is identical to the behavior of the Unique Lines tool. - Unique lines only - Removes all
lines
that have duplicates, leaving only thoselines
that were already unique. The order of resultinglines
remains unchanged. - Duplicated lines only - Removes all
lines
that do not have duplicates, leaving only thoselines
that do have duplicates. The resultinglines
are uniqued in the process, thus each resultingline
appears only once in the results. The order of resultinglines
remains unchanged.
Optionally, if the Count duplicates option is checked, the tool counts number of duplicates of each line
and adds these numbers to the results. Each resulting line then contains a number of its duplicates, written in brackets, in front of that line.
Additionally, Leave empty lines option may be specified to spare all empty lines
from being removed, counted or otherwise modified. This can, for example, prevent unwanted paragraph
joining. If this option is not specified, even empty lines get counted and/or removed, which might not be always desired.
And finally, Ignore case option may be specified to ignore case
when matching duplicates.
how much wood would a woodchuck chuck if a woodchuck could chuck wood |
wood a woodchuck chuck |
(1) how much (2) wood (1) would (2) a woodchuck (2) chuck (1) if (1) could |
See also Unique Lines tool.
Columns, Numbers... (Alt+Ctrl+Y)
Cuts portions of lines
from the selection and replaces the old lines
with new generated lines
according to given Output mask. The Output mask may contain any text, which is duplicated to every new generated line, and may include these special variables, which are computed on the fly and have the following purpose:
- %0 — inserts a copy of the entire original line.
- %1 - %9 — inserts a line portion, cut from the original line according to rules specified in corresponding tab. See below.
- %d — inserts a decimal number from the Counter. See below.
- %x — inserts a lower case hexadecimal number from the Counter. See below.
- %X — inserts an upper case hexadecimal number from the Counter. See below.
- %b — inserts a binary number from the Counter. See below.
- %o — inserts an octal number from the Counter. See below.
- %r — inserts a random number from the Random number generator. See below.
- %l0 — inserts length, in characters, of the original line.
- %l1 - %l9 — inserts length of a line portion, cut from the original line according to rules specified in corresponding tab. See below.
- %n — inserts a newline. Note: This variable results in generating sequence of multiple lines for each of the input lines.
- %% — inserts a single % character. Note: Since % character is used to prefix variables, doubled %% must be used in order to place plain % into the results. Note: Using a simple % character, not followed by a recognized variable, is considered an error in the Output mask to prevent possible inconvenience from future improvements of the tool.. ;)
All variables (except %n) may be supplied an aligning specifier. Aligning specifier must appear directly after the % prefix character. It is used to align values of the variable into a neat fixed-width column. Width of such column is determined by examining the variable for all lines and taking the longest length. Aligning specifier may be one of the following:
- < — aligns the variable to the left, using spaces to fill the shorter lines from right.
- ! — aligns the variable to the center, using spaces to fill the shorter lines from both sides.
- > — aligns the variable to the right, using spaces to fill the shorter lines from left.
- + — aligns the variable to the right, using zeros to fill the shorter lines from left.
Note: Aligning a variable into a fixed-width column does not necessarily guarantee a neat visual column in the results. There are two reasons for having the column scattered in the results:
- If proportional font is used for text displaying, it may render different characters with different extents, resulting in different visual positions of respective character positions.
- If multiple variables are used in the Output mask, all of them should include an aligning specifier to ensure nothing else but neat aligned columns in the results. This is because variable alignment is computed separately for each variable, and is thus insensitive to other portions of currently generated line. Therefore, if one variable results in a non-fixed-width column, there is no guaranteed way to ensure further visual column alignment (although variables themselves would continue to get aligned neatly into their own private columns).
Some variables require a Counter to be defined. The tool uses Start number to initialize the Counter before processing the selection. Then, for each line of the selection, increments the Counter by a Step.
Note: Counter always produces the same number for the same line, even if used multiple times per line.
Some variables require a Random number generator. The generator produces decimal numbers between Min and Max (inclusive) every time a variable requires a random number.
Note: Unlike Counter, Random number generator produces a different number each time it is used, even if used multiple times for the same line.
Note: Random number generator expects the Min to be less than Max. If Min is greater or equal to Max, numbers between 0 and 4294967295 are generated.
Warning: Although the tool uses a more complex pseudo-random generator (than a linear congruential generator), it is not safe to assume that the generator is cryptographically secure. This tool should not be used for encryption purposes if real sturdy protection is expected, since the pseudo-random generator is not constructed to withstand real cryptanalysis. It is only safe to assume that the generator is not easily predictable without advanced cryptanalysis — which is acceptable for most common tasks.
Optionally, Modify non-empty lines only can be used to keep all empty lines
intact by this tool.
Note: The Preview option can be used to toggle on/off Preview pane. Preview pane shows a small portion of lines transformed by values currently set in the tool dialog. Be aware that preview is always generated from the current selection. If there is no selection, then there is nothing to preview. Also, since only a small portion of the selection is used for preview, alignment of columns is computed for that portion only (excluding the rest of the selection), which may result in shorter lines.
Cutting line portion
Cutting portion of a line
is divided into two successive parts. First, columns
are cut from the line
, by either:
- Entire line, which keeps the entire original
line
. - Columns, which allows to specify one or more subsequent
columns
between columns from and columns to (inclusive). Individualcolumns
are separated by characters from Delimiting characters, which means that theline
is scanned for thesedelimiting characters
, and wherever adelimiting character
is found (any character from Delimiting characters), oldcolumn
ends before thisdelimiter
and a newcolumn
begins after thisdelimiter
. There can be as manydelimiting characters
as necessary and all of them delimitcolumns
equally and indiscriminately.- Optionally, Delimit by entire phrase rather than separate characters can be used to stop treating Delimiting characters as a set of individual characters, and scan for an entire
delimiting phrase
instead. - Optionally, Treat any sequence of delimiters as single delimiter can be used to count several successive
delimiters
as a singledelimiter
. This can be useful, for example, if inputcolumns
are aligned by spaces into neat visual columns, where each twocolumns
are delimited by an arbitrary-length sequence of spaces. Such sequences need to be treated as indivisible columndelimiters
.- Note that even different delimiting characters are treated as a single indivisible
delimiter
, if found in sequence.
- Note that even different delimiting characters are treated as a single indivisible
- Optionally, Calculate columns backwards: from right to left can be used to numerate the
columns
from the end of line rather than the usual way. Note, however, that this only affects how thecolumns
are numbered before they are cut; the text of thecolumns
is not reversed. - Note:
Delimiters
are not included within thecolumn
being cut. However, if two or more subsequentcolumns
are cut together, innerdelimiters
are not removed and become part of the line portion being cut. - Note: Delimiting characters are always
case sensitive
. - Examples: A line HELLO WORLD would be divided into:
- two columns (HELLO and WORLD) — if delimited by a Space character;
- four columns (H, LL, W and RLD) — if delimited by a set of EO characters;
- four columns (HE, {empty}, O WOR and D) — if delimited by an L character;
- but only three columns (HE, O WOR and D) — if Treat any sequence of delimiters as single delimiter option is turned on;
- and only one column (HELLO WORLD) — if delimited by an X character,
lower case
e character, or if delimited by no characters — this is because none of these characters are found on the examined line.
- Optionally, Delimit by entire phrase rather than separate characters can be used to stop treating Delimiting characters as a set of individual characters, and scan for an entire
Note: Columns
are cut for each line separately, therefore the total number of columns
on a line may vary from line to line. If specified column
number is beyond the total number of columns
, empty zero-length portion is cut for such column
from that line. Therefore, it is allowed to cut columns
2-7, even though some lines do not have enough columns
to offer.
After the first part (cutting columns
from the line), the resulting portion of the line can be further cropped by turning Use only characters option on, and specifying a range of character positions between from position and to position. This cuts off everyting before the from position and everyting after the to position.
- Calculate the position backwards: from right to left can be used to numerate the character positions from the end of line rather than the usual way. Note, however, that this only affects how the positions are numbered before they are cropped; the text itself is not reversed.
Note: Range of character positions is always cropped after columns
are cut. If a range is specified beyond currently cut columns
, empty zero-length portion is cropped from that line, even if the original line continues after the cut columns
. In other words, range of character positions cannot bring back what has already been cut off by previous step.
Note: There is currently no way to cut columns
after cropping a range of character positions.
Note: Column preview button displays a small portion of lines transformed by current dialog values. Be aware that preview is always generated from the current selection. If there is no selection, then there is nothing to preview.
Examples
In the examples below, we use the following input text:
No;Name;Race;Age 1;Amy;labrador;4 2;Konie;bordercollie;3 3;Kvido;mongrel;2 |
Simple numbering
Example of a simple numbering Output mask: %+d, %1. This mask will cut a line portion (specified for variable %1) from each line and place it in the results after a decimal number, colon and a space. The numbers will be neatly aligned to the right by leading zeroes where necessary, in order to have the same count of digits.
1, Race 2, labrador 3, bordercollie 4, mongrel |
Columnizing trick
Example of a columnizing Output mask: %<1 | %2. If variable %1 cuts the first line column, and the variable %2 cuts the rest of the line, this mask can be used to visually columnize the list from the example above. This is done by aligning the variable %1 (the first column) to the left, adding a glue like | , and then appending the rest of the line. However, since this would columnize the first column only, one needs to invoke this tool several times in a row, until all columns are transformed. The main reason to do it this way is that it can columnize quite many columns very quickly once this is set up correctly.
Note: Make sure not to use the same delimiter for new columns that is used for old columns. Doing so would result in columnizing the first column over and over again. The main idea in this trick is to make the tool work subsequently thru all old columns, converting them into new columns one by one. The tool may not be allowed to confuse new and old columns, or it won't pan out. In this example, old columns are delimited by ; while new columns are delimited by | , which is mutually exclusive as required.
No | Name | Race | Age 1 | Amy | labrador | 4 2 | Konie | bordercollie | 3 3 | Kvido | mongrel | 2 |
Note: The example above only works for aligning to the left. To align to the right, columnizing backwards must be applied, from the last column to the first (i.e. the principle of working thru columns must be reversed). There is no way to center the columns this way (though one can always cut each column separately into a different variable and then specify a mask, which enumerates all the variables).
Tip: Persistent selection setting might come handy for this technique. See chapter Tools page of the Settings dialog for more details.
Columns, Numbers... (Alt+Ctrl+Y)
Cuts portions from eachlineand then gnerates newlinesaccording to the given Output mask. The mask may contain any text, and may also include these special variables: * %0 - returns the entire original line. * %1-%9 - return the columns cut according to rules specified in the corresponding tab. * %d - returns a decimal number from the Counter. You may specify the Start and the Step. * %x - returns a lower case hexadecimal number from the Counter. * %X - returns an upper case hexadecimal number from the Counter. * %b - returns a binary number from the Counter. * %o - returns an octal number from the Counter. * %n - returns a simple newline. All these veriables might be furthermore qualified with an aligning specifier: * < - aligns the entire column to the left, using spaces to fill the shorter lines from right. * > - aligns the entire column to the right, using spaces to fill the shorter lines from left. * + - aligns the entire column to the right, using 0 to fill the shorter lines from left. * ^ - aligns the entire column to the center, using spaces to fill the shorter lines from both sides. Optionally, you may choose to Modify non-empty lines only, if you need to keep theemptylines intact. Example of an Output mask. This mask will cut the first column from each line and place it in the results after a decimal number, colon and a space. The numbers will be aligned to the right by zeroes, so that they all have the same number of digits:
%+d, %1 |