Difference between revisions of "Lines tools"

From TED Notepad
 
(20 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<noinclude>{{manversion|5.3.0.4}}__NOTOC__</noinclude>
+
<noinclude>{{manversion|6.3.0.8|menu}}__NOTOC__</noinclude>
 
+
{{:Indent Lines}}
====Indent (Ctrl+Tab)====
+
{{:Unindent Lines}}
 
+
{{:Quote Lines}}
Indents each {{defined|line}} of the selection with a Tab character.
+
{{:Unquote Lines}}
 
+
{{:Shift Lines Left}}
Note: The selection always persists in this tool.
+
<!-- ++++++++ -->
 
+
{{:Close Lines}}
====Unindent (Ctrl+Shift+Tab)====
+
{{:Unclose Lines}}
 
+
{{:Shift Lines Right}}
Removes the first character on each {{defined|line}} of the selection, if the character is a {{defined|white-space}}.
+
{{:Trim Tail Spaces}}
 
+
{{:Trim Empty Lines}}
====Quote Mail (Ctrl+Q)====
+
<!-- ++++++++ -->
 
+
{{:Tabify}}
Indents (quotes) each {{defined|line}} of the selection with a {{string|<nowiki>&gt;_</nowiki>}} phrase exactly the same way as a standard mail client would do upon replying to a message.
+
{{:Untabify}}
 
+
<!-- ++++++++ -->
Note: The selection always persists in this tool.
+
{{:Remove Empty Lines}}
 
+
{{:Collapse Empty Lines}}
====Quote/Indent... (Alt+Ctrl+Q)====
+
<!-- ++++++++ -->
   
+
{{:Unique Lines}}
Asks for a {{field|Quote}} phrase to work with and then indents (quotes) the selection with the specified phrase at the beginning of each {{defined|line}}. Optionally, only {{defined|non-empty lines}} can be quoted.
+
{{:Find Duplicates}}
 
+
<!-- ++++++++ -->
{{example_start}}Example: {{mycomment|(an e-mail received from a user)}}
+
{{:Columns, Numbers}}
{{example_body}}<nowiki>----- Original Message -----
+
{{:Grep, Filter by Pattern}}
</nowiki>{{example_select|<nowiki>Great notepad!
 
 
 
Tabs, you need tabs for multiple documents. Cosmetic, supeficial,........
 
of course. But that's what people are looking for these days.</nowiki>}}
 
{{example_end}}
 
 
 
{{example_start}}Result, using {{field|Quote}}: {{string|<nowiki>&gt;_</nowiki>}} and {{field|Only non-empty lines}} checked:
 
{{example_body}}<nowiki>----- Original Message -----
 
> Great notepad!
 
 
 
> Tabs, you need tabs for multiple documents. Cosmetic, supeficial,........
 
> of course. But that's what people are looking for these days.</nowiki>
 
{{example_end}}
 
 
 
{{tip}} If you are writting a list (or a table) in an HTML document, you may write all the lines of such a list first without having to bother with all the HTML tags. Then select all the lines, hit this {{feature|Indent/Quote Selection...}} tool (hotkey {{hotkey|Alt+Ctrl+Q}}) and enter phrase like {{string|<nowiki>&lt;LI&gt;</nowiki>}} as the {{field|Quote}} phrase.
 
 
 
====Unquote (Ctrl+Shift+Q)====
 
 
 
Takes the very first character of the selection as a ''quoting character''. Then removes the first character on each {{defined|line}} of the selection, if the character is the ''quoting character''.
 
 
 
Note: It is very similar to the {{feature|Unindent Selection}} tool, but it is not space-oriented only.
 
 
 
====Shift Left (Alt+Ctrl+Shift+Q)====
 
 
 
Removes the first character from each {{defined|line}} of the selection, no matter what it is.
 
 
 
Note: Tabs are treated as single characters.
 
 
 
====Tabify (Alt+Ctrl+O)====
 
 
 
Tabifies the indentation of the selection by replacing leading Spaces with Tabs on each {{defined|line}}. While replacing, the Spaces are being grouped together according to the {{field|Tab Size}} setting. Each set of Spaces is then replaced by a Tab.
 
 
 
If Tabs and Spaces are mixed together on the beginning of a line, the total {{defined|white-space}} outcome is calculated first and then Tabs and then Spaces are used to fill the occupied ''white space''. Tabs always precede Spaces and Spaces are used only, when a Tab would extend the original {{defined|white-space}} outcome.
 
 
 
Note: Using this tool sould not generate any visible changes, when using a fixed-width fonts. However, some proportional fonts do not use the average character width for Spaces, thus a Tab may seem to be longer than a set of Spaces.
 
 
 
Note: This tool does not modify other than leading Spaces.
 
 
 
====Untabify (Ctrl+Shift+O)====
 
 
 
Untabifies the indentation of the selection by replacing leading Tabs with Spaces on each {{defined|line}}. While replacing, the Tabs are being replaced by multiple Spaces according to the {{field|Tab Size}} setting.
 
 
 
If Tabs and Spaces are mixed together on the beginning of a line, the total {{defined|white-space}} outcome is calculated first and then Spaces are used to fill the occupied ''white space''.
 
 
 
Note: Using this tool sould not generate any visible changes, when using a fixed-width fonts. However, some proportional fonts do not use the average character width for Spaces, thus a Tab may seem to be longer than a set of Spaces.
 
 
 
Note: This tool does not modify other characters than leading Tabs.
 
 
 
====Close... (Alt+Ctrl+C)====
 
 
 
Asks for a {{field|Close with}} phrase to work with and then closes each {{defined|line}} of the selection with the specified phrase. Optionally, only {{defined|non-empty lines}} can be closed.
 
 
 
{{example_start}}Result, using {{field|Close with}}: {{string|<nowiki>&lt;br&gt;</nowiki>}}; see example above:
 
{{example_body}}<nowiki>----- Original Message -----
 
Great notepad!<br>
 
<br>
 
Tabs, you need tabs for multiple documents. Cosmetic, supeficial,........<br>
 
of course. But that's what people are looking for these days.<br></nowiki>
 
{{example_end}}
 
 
 
{{tip}} As the example above shows, if you are writting an HTML document, you may write all the text of such a document first without having to bother with all the HTML tags. Then select the text, hit this {{feature|Close Lines...}} tool (hotkey {{hotkey|Alt+Ctrl+C}}) and enter whatever phrase is needed after each line (e.g. a {{string|<nowiki>&lt;bt&gt;</nowiki>}} tag).
 
 
 
{{tip}} According to the tips and examples above, you may simply combine the {{feature|Indent/Quote Selection...}} tool with {{feature|Close Lines...}} tool in order to write paragraphs in an HTML document without having to bother with {{string|<nowiki>&lt;p&gt;</nowiki>}} tags at first. Write all the paragraphs first, each one on a single line (use {{feature|word wrapping}} (hotkey {{hotkey|Ctrl+W}}) in order to see entire paragraphs wrapped into several lines). Then select all the paragraphs and use both {{feature|Indent/Quote Selection...}} and {{feature|Close Lines...}} tools in order to add the {{string|<nowiki>&lt;p&gt;</nowiki>}} and {{string|<nowiki>&lt;/p&gt;</nowiki>}} tags.
 
 
 
====Trim Spaces (Ctrl+Shift+C)====
 
 
 
Removes all {{defined|white-spaces}} from the end of each {{defined|line}} of the selection.
 
 
 
====Columns, Numbers... (Alt+Ctrl+Y)====
 
 
 
Cuts portions from each {{defined|line}} and then gnerates new {{defined|lines}} according to the given {{field|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 {{field|Counter}}. You may specify the {{field|Start}} and the {{field|Step}}.
 
* '''%x''' - returns a lower case hexadecimal number from the {{field|Counter}}.
 
* '''%X''' - returns an upper case hexadecimal number from the {{field|Counter}}.
 
* '''%b''' - returns a binary number from the {{field|Counter}}.
 
* '''%o''' - returns an octal number from the {{field|Counter}}.
 
* '''%n''' - returns a simple newline.
 
<!--
 
* '''%i''' - returns a lower case Roman number from the {{field|Counter}}.
 
* '''%I''' - returns a upper case Roman number from the {{field|Counter}}.
 
* '''%a''' - returns a lower case letter from the {{field|Counter}}.
 
* '''%A''' - returns a upper case letter from the {{field|Counter}}.
 
-->
 
 
 
All these veriables might be furthermore qualified with an aligning specifier:
 
* '''&lt;''' - aligns the entire column to the left, using spaces to fill the shorter lines from right.
 
* '''&gt;''' - 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 {{field|Modify non-empty lines only}}, if you need to keep the {{defined|empty}} lines intact.
 
 
 
 
 
Ecample of an {{field|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:
 
{{example_start}}
 
{{example_body}}<nowiki>%+d, %1</nowiki>
 
{{example_end}}
 
 
 
====Unique (Alt+Ctrl+X)====
 
 
 
Searches the selection for equal {{defined|lines}} and removes all duplicates. The order of the uniqued lines remains unchanged and from each two equal lines, the second one is removed.
 
 
 
Note: Use {{hotkey|'''Shift'''+Alt+Ctrl+X}} hotkey in order to {{defined|ignore case}} when matching duplicates.
 
 
 
{{example_start}}Example:
 
{{example_body}}{{example_select|<nowiki>how much
 
wood
 
would
 
a woodchuck
 
chuck
 
if
 
a woodchuck
 
could
 
chuck
 
wood</nowiki>}}
 
{{example_end}}
 
 
 
{{example_start}}Result:
 
{{example_body}}<nowiki>how much
 
wood
 
would
 
a woodchuck
 
chuck
 
if
 
could</nowiki>
 
{{example_end}}
 
 
 
{{tip}} If you need, for example, a complete word listing of a document, use the {{feature|Extended Replace}} tool in order to replace all the spaces, commas, dots, etc. by new lines. Then use this {{feature|Unique Lines}} tool, which will give you the complete listing of all words.
 
 
 
====Find duplicates... (Ctrl+Shift+X)====
 
 
 
Works the same way as the {{feature|Unique Lines}} tool does, but allows more options affecting the behavior of the tool:
 
 
 
*{{field|All lines}} - identical to the behavior of the Unique Lines tool.
 
*{{field|Only unique lines}} - only lines that does not have duplicates are included in the result.
 
*{{field|Only duplicated lines}} - only lines that have at least one duplicate are included in the result.
 
 
{{example_start}}Result of {{field|Only duplicated lines}}; see example above:
 
{{example_body}}<nowiki>wood
 
a woodchuck
 
chuck
 
</nowiki>
 
{{example_end}}
 
 
 
The {{field|Count duplicates}} option adds to the result the actual numbers of equal lines. Each resulting line will contain a number of its duplicates, written in brackets before the line.
 
 
 
{{example_start}}Result of {{field|Count duplicates}}; see example above:
 
{{example_body}}<nowiki>(1) how much
 
(2) wood
 
(1) would
 
(2) a woodchuck
 
(2) chuck
 
(1) if
 
(1) could</nowiki>
 
{{example_end}}
 
 
 
Additionally, {{field|Ignore case}} option may be specified to {{defined|ignore case}} when matching duplicates. {{field|Leave empty lines}} option may be specified to spare {{defined|empty lines}} from being uniqued to prevent joining of separate {{defined|paragraphs}}.
 
 
 
====Remove Empty (Ctrl+Shift+V)====
 
 
 
Removes all {{defined|empty lines}} from the selection. Other lines remain untouched.
 

Latest revision as of 23:22, 5 October 2021

This section is up to date for TED Notepad version 6.3.1.0.
Control page Control:menu:Lines tools

Indent (Ctrl+Tab)

[Section link: Indent Lines]

Indents each line of the selection with a Tab character. Does not modify empty lines.

Note: Indents with spaces instead of a Tab, if Insert spaces instead of Tab setting is turned on. The number of spaces inserted can be specified thru Tab Size setting. See chapter Edit page of the Settings dialog for more details.

Note: If Tab key indents multiple lines setting is turned on, this tool can be invoked thru simple Tab key (as long as multiple lines are selected of course).

Note: The selection always persists in this tool.

Example:
if (IsNonEmpty (line)) Indent (line);
Result:
if (IsNonEmpty (line)) Indent (line);

See also Unindent Lines, Quote Lines and Tabify tools.

Unindent (Ctrl+Shift+Tab)

[Section link: Unindent Lines]

Removes the first character on each line of the selection, if that character is a white-space.

Note: This tool does not remove anything else but white-spaces.

Note: If Insert spaces instead of Tab setting is turned on, this tool may unindent as many spaces as the Tab Size setting specifies, making it the counterpart to the Indent Lines tool.

Note: If Tab key indents multiple lines setting is turned on, this tool can be invoked thru simple Shift+Tab key (as long as multiple lines are selected of course).

Note: The selection always persists in this tool.

Example:
if (IsIndented (line)) Unindent (line);
Result:
if (IsIndented (line)) Unindent (line);

See also Indent Lines, Unquote Lines, Shift Lines Left and Tabify tools.

See also Trim Tail Spaces and Trim Empty Lines tools.

Quote.. (Alt+Ctrl+Q)

[Section link: Quote Lines]

Asks for a Quote phrase to work with and then quotes (i.e. indents) the selection with the specified phrase at the beginning of each line.

Optionally, Quote non-empty lines only can be used to quote non-empty lines only, which ensures that empty lines are not modified at all.

Optionally, using the Skip leading spaces, the quoting phrase may be inserted just after all leading white-spaces on each line. This way, any current line indentation is kept unmodified, and the quoting phrase is appended to that indentation, before the first graph (i.e. non-white-space) character.

Note: When quoting of empty lines is allowed, and leading white-spaces are to be skipped, special consequential case occurs. On empty lines, quoting phrase is appended, because the skipped leading white-spaces is all that those line contain.

Note: The selection always persists in this tool.

Example: (an e-mail received from a user)
----- Original Message ----- Great notepad! Tabs, you need tabs for multiple documents. Cosmetic, supeficial, of course. But that's what people are looking for these days.
Result, using Quote: and Quote non-empty lines only checked:
----- Original Message ----- > Great notepad! > Tabs, you need tabs for multiple documents. Cosmetic, supeficial, > of course. But that's what people are looking for these days.

Tip: Combine the Quote Lines tool with the Close Lines tool in order to write paragraphs or lists in HTML documents without having to bother with <p> or <li> tags while writing. Write all paragraphs first, each one on a separate line (you may use Word Wrap (hotkey Ctrl+W) to see long lines automatically wrapped into several lines, since the Word Wrap does not affect tools). When done, select all the lines and use both Quote Lines and Close Lines tools to add the <p> and </p> tags (or <li> and </li> tags) to each line.

Example:
Great notepad! Tabs, you need tabs for multiple documents. Cosmetic, supeficial, of course. But that's what people are looking for these days.
Result, quoting with <li> and closing with </li>:
<li>Great notepad!</li> <li>Tabs, you need tabs for multiple documents. Cosmetic, supeficial,</li> <li>of course. But that's what people are looking for these days.</li>

Unquote (Ctrl+Shift+Q)

[Section link: Unquote Lines]

Takes the very first character of the selection as a quoting character. Then removes the first character on each line of the selection, if that character is the quoting character.

Note: This is very similar to the Unindent Lines tool, but it is not white-space-oriented only, and thus can be used to remove any common character from the beginning of lines.

Note: The selection always persists in this tool.

Example:
One Ring to rule them all, One Ring to find them,
Result:
ne Ring to rule them all, ne Ring to find them,

See also Quote Lines, Unindent Lines and Shift Lines Left tools.

See also Unclose Lines tool.

Shift Left (Alt+Ctrl+Shift+Q)

[Section link: Shift Lines Left]

Removes the first character from each line of the selection, no matter what that character is.

Note: Tabs are treated as single characters.

Note: The selection always persists in this tool.

Example:
One Ring to bring them all and in the darkness bind them.
Result:
ne Ring o bring them all nd in the darkness ind them.

See also Unindent Lines, Unquote Lines and Tabify tools.

See also Shift Lines Right tool.

Close.. (Alt+Ctrl+C)

[Section link: Close Lines]

Asks for a Close phrase to work with and then closes each line of the selection with the specified phrase, i.e. appends the specified phrase to each line.

Optionally, Close non-empty lines only can be used to close non-empty lines only, which ensures that empty lines are not modified at all.

Optionally, using the Skip tail spaces, the closing phrase may be inserted just before all tail white-spaces on each line. This way, any current end-of-line white-spaces are kept unmodified, and the closing phrase is prepended to those white-spaces, after the last graph (i.e. non-white-space) character.

Note: When closing of empty lines is allowed, and tail white-spaces are to be skipped, special consequential case occurs. On empty lines, closing phrase is prepended, because tail white-spaces is all that those line contain.

Note: The selection always persists in this tool.

Example: (an e-mail received from a user)
----- Original Message ----- Great notepad! Tabs, you need tabs for multiple documents. Cosmetic, supeficial, of course. But that's what people are looking for these days.
Result, using Close: <br> and Close non-empty lines only checked:
----- Original Message ----- Great notepad!<br> Tabs, you need tabs for multiple documents. Cosmetic, supeficial,<br> of course. But that's what people are looking for these days.<br>

Tip: Combine the Quote Lines tool with the Close Lines tool in order to write paragraphs or lists in HTML documents without having to bother with <p> or <li> tags while writing. Write all paragraphs first, each one on a separate line (you may use Word Wrap (hotkey Ctrl+W) to see long lines automatically wrapped into several lines, since the Word Wrap does not affect tools). When done, select all the lines and use both Quote Lines and Close Lines tools to add the <p> and </p> tags (or <li> and </li> tags) to each line.

Example:
Great notepad! Tabs, you need tabs for multiple documents. Cosmetic, supeficial, of course. But that's what people are looking for these days.
Result, quoting with <li> and closing with </li>:
<li>Great notepad!</li> <li>Tabs, you need tabs for multiple documents. Cosmetic, supeficial,</li> <li>of course. But that's what people are looking for these days.</li>

Unclose (Ctrl+Shift+C)

[Section link: Unclose Lines]

Takes the very last character of the first line of the selection as a closing character. Then removes the last character on each line of the selection, if that character is the closing character.

Note: This is very similar to the Trim Tail Spaces tool, but it is not white-space-oriented only, and thus can be used to remove any common character from the end of lines.

Note: The selection always persists in this tool.

Example:
One Ring to rule them all One Ring to find them One Ring to bring them all and in the darkness bind them
Result:
One Ring to rule them al One Ring to find them One Ring to bring them al and in the darkness bind them

See also Close Lines, Trim Tail Spaces and Shift Lines Right tools.

See also Unquote Lines tool.

Shift Right (Alt+Ctrl+Shift+C)

[Section link: Shift Lines Right]

Removes the last character from each line of the selection, no matter what that character is.

Note: The selection always persists in this tool.

Example:
One Ring to rule them all, One Ring to find them, One Ring to bring them all and in the darkness bind them.
Result:
One Ring to rule them all One Ring to find them One Ring to bring them al and in the darkness bind them

See also Unclose Lines and Trim Tail Spaces tools.

See also Shift Lines Left tool.

Trim Tail Spaces (Ctrl+Shift+A)

[Section link: Trim Tail Spaces]

Removes all white-spaces from the end of each line of the selection.

Example:
One little, two little, three little Indians.
Result:
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 Lines (Alt+Ctrl+Shift+A)

[Section link: Trim Empty Lines]

Removes all white-spaces from each empty line of the selection.

Note: Does not modify non-empty lines.

Example:
One little, two little, three little Indians.
Result:
One little, two little, three little Indians.

See also Trim Tail Spaces and Unindent Lines tools.

Tabify (Ctrl+Shift+O)

[Section link: Tabify]

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)

[Section link: Untabify]

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 (Ctrl+Shift+V)

[Section link: Remove Empty Lines]

Removes all empty lines from the selection.

Note: Does not modify non-empty lines.

Example:
One little, two little, three little Indians.
Result:
One little, two little, three little Indians.

See also Collapse Empty Lines tool.

Collapse Empty (Alt+Ctrl+Shift+V)

[Section link: Collapse Empty Lines]

Collapses all sequences of empty lines in the selection. While collapsing, each continuous sequence of empty lines is reduced to only one line, leaving the first of those lines intact, and removing all following empty lines.

Note: Does not modify non-empty lines.

Example:
One little, two little, three little Indians.
Result:
One little, two little, three little Indians.

See also Remove Empty Lines tool.

Unique (Ctrl+Shift+X)

[Section link: Unique Lines]

Searches the selection for duplicate lines and removes all duplicates. The order of the uniqued lines remains unchanged and from each two equal lines, the second one is removed.

Note: Use Alt+Ctrl+Shift+X hotkey to ignore case while searching for duplicate lines.

Note: This tool is actually a shortcut to the Find Duplicates tool, which allows to specify more options on how to search for duplicate lines.

Example:
how much wood would a woodchuck chuck if a woodchuck could chuck wood
Result:
how much wood would a woodchuck chuck if could

See also Find Duplicates tool.

Find duplicates.. (Alt+Ctrl+X)

[Section link: Find Duplicates]

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 resulting lines 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 those lines that were already unique. The order of resulting lines remains unchanged.
  • Duplicated lines only - Removes all lines that do not have duplicates, leaving only those lines that do have duplicates. The resulting lines are uniqued in the process, thus each resulting line appears only once in the results. The order of resulting lines 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.

Example:
how much wood would a woodchuck chuck if a woodchuck could chuck wood
Result of Duplicated lines only:
wood a woodchuck chuck
Result of All lines (remove duplicates) with Count duplicates:
(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)

[Section link: Columns, Numbers]

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:

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:

Example:
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.

The variable %1 cuts the third column (columns separated by ; delimiter) and the Counter is set to Start: 1 and Step: 1:
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.

The variable %1 cuts column 1 (columns separated by ;), variable %2 cuts columns 2-4 (separated by ; as well). After using this tool for 3 times:
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.

Grep, Filter by Pattern.. (Alt+Ctrl+P)

[Section link: Grep, Filter by Pattern]

grep is a command-line utility for searching plain-text for lines that match a regular expression. Its name comes from the ed command g/re/p, which has the same effect: doing a global search with the regular expression and printing all matching lines. Wikipedia

Searches for a given Find phrase within the selection. It can then either filter out all non-matching lines, or alternatively filter out all matching lines.

Regular expressions can be used as the Find search pattern.

Choose Objective of the filtering

The Keep matching lines option keeps all matching lines and removes any non-matching lines.

The Remove matching lines option removes all matching lines and keeps any non-matching lines.

The Also keep empty lines option can be used to also keep any empty lines on top of matching lines. This option is only available with Keep matching lines.

The Only matched parts of lines option

The Add line numbers option can be used to add the original line numbers to the results. Note that these line numbers are counted from the beginning of the selection the tool is used on.

Add Context of extra lines

The Extra lines before and Extra lines after fields can be used to specify extra lines to be considered as part of the match when keeping or removing the matching or non-matching lines. Specifically,

Note: Context before or after is not available with Only matched parts of lines turned on.

Note: With Also keep empty lines, those empty lines are not considered matching simply by being empty lines. The are kept for convenience, but do not by themselves add any Context. Only lines matched via the Find phrase, empty of not, trigger adding Context.

More Options on searching

By default, the search is case insensitive. The Match case option can be used to make the search case sensitive.

The Whole words option can be used to restrict the search to only those matches, which start and end at word boundaries. Note that a match itself might contain non-word characters, since only the boundaries of the match are probed. Therefore, the last character before the match and the first character after the match may not be word characters; while the first character and the last character of the match must be word characters.

The Whole lines option can be used to restrict the search to only those matches, which start at a line beginning and end at a line end. Note that a match itself might contain a newline, since only the boundaries of the match are probed.

The Escapes option can be used to allow entering newlines and Tab characters into the Find phrase. Use \n sequence to encode a newline, use \t to encode a Tab character, and use \\ to encode a simple backslash (\) character wherever a confusion with other escapes could arise.

Note: A newline escape (\n) matches any kind of newline (Windows, Unix, Mac). A newline escape matches exactly one newline, i.e. use \n\n in order to match two consecutive newlines, etc.

The RegExps option can be used to turn the Regular expressions engine on. When Regular expressions are enabled, Find is parsed as a regular expression pattern. See chapter Regular expressions for more details on supported regular expressions syntax.

Note: Invalid or faulty regular expression patterns result in tool refusing to work until the pattern is corrected.

Further notes

Note: Search patterns are limited to 64 KiB. Prior to version 6.3, search patterns were limited to 8 KiB.

Note: The tool posts Total matches to the Status Bar. This number may be different than the number of resulting lines, if multiple matches are found per line.