Catalog / Regex & Text Manipulation in IDEs/Editors

Regex & Text Manipulation in IDEs/Editors

A quick reference guide to using regular expressions and text manipulation features within popular Integrated Development Environments (IDEs) and text editors, streamlining coding and text editing tasks.

Basic Regex Operations

Finding Text

Find/Search

Locates the first or next occurrence of a specified text or regex pattern.

Example:
Ctrl+F (Windows/Linux) or Cmd+F (macOS)

Find All

Highlights or lists all occurrences of a specified text or regex pattern.

Example:
Often available in advanced search options.

Incremental Search

Starts searching as you type, immediately jumping to the first match.

Example:
Ctrl+I (Emacs)

Replacing Text

Replace

Replaces the first found occurrence of a pattern with a specified replacement string.

Example:
Ctrl+H (Windows/Linux) or Cmd+Option+F (macOS)

Replace All

Replaces all occurrences of a pattern with a specified replacement string.

Example:
Usually an option within the Replace dialog.

Replace with Regex

Allows using regular expressions both for finding and replacing text, enabling complex transformations.

Example:
Enable regex option in the Replace dialog.

Common Regex Symbols

. - Matches any single character (except newline).

* - Matches zero or more occurrences of the preceding character or group.

+ - Matches one or more occurrences of the preceding character or group.

? - Matches zero or one occurrence of the preceding character or group (optional).

[] - Defines a character class; matches any character within the brackets.

() - Groups characters or patterns; captures the matched group.

| - Acts as an ‘or’ operator, matching either the expression before or after the pipe.

Advanced Regex Features

Character Classes

\d

Matches any digit (0-9).

Example:
\d+ matches one or more digits.

\w

Matches any word character (a-z, A-Z, 0-9, and underscore).

Example:
\w+ matches one or more word characters.

\s

Matches any whitespace character (space, tab, newline).

Example:
\s+ matches one or more whitespace characters.

\D

Matches any non-digit character.

Example:
\D+ matches one or more non-digit characters.

\W

Matches any non-word character.

Example:
\W+ matches one or more non-word characters.

\S

Matches any non-whitespace character.

Example:
\S+ matches one or more non-whitespace characters.

Anchors

^

Matches the beginning of a line.

Example:
^Hello matches lines starting with ‘Hello’.

$

Matches the end of a line.

Example:
World$ matches lines ending with ‘World’.

\b

Matches a word boundary (the position between a word character and a non-word character).

Example:
\bword\b matches the whole word ‘word’.

Quantifiers

{n}

Matches exactly n occurrences of the preceding character or group.

Example:
\d{3} matches exactly three digits.

{n,}

Matches n or more occurrences of the preceding character or group.

Example:
\d{3,} matches three or more digits.

{n,m}

Matches between n and m occurrences of the preceding character or group.

Example:
\d{3,5} matches between three and five digits.

Text Manipulation Techniques

Case Conversion

Uppercase

Convert selected text or the entire document to uppercase.

Example:
Select text, then use Edit -> Convert to Uppercase (varies by editor).

Lowercase

Convert selected text or the entire document to lowercase.

Example:
Select text, then use Edit -> Convert to Lowercase (varies by editor).

Title Case

Convert selected text to title case (capitalize the first letter of each word).

Example:
Plugins or extensions might be required.

Indentation and Formatting

Auto-Indent

Automatically adjusts indentation based on the code structure.

Example:
Often triggered automatically or via Edit -> Indent.

Reformat Code

Applies predefined code style rules to the entire document or selection.

Example:
Often available through IDE’s code formatting options.

Tab/Untab

Insert or remove tabs/spaces at the beginning of lines.

Example:
Select lines, then use Tab or Shift+Tab.

Line Operations

Join Lines

Combine selected lines into a single line.

Example:
Often Ctrl+J or Edit -> Join Lines.

Split Lines

Split a line at the cursor position into two lines.

Example:
Usually Enter key.

Duplicate Lines

Duplicate the selected lines.

Example:
Ctrl+Shift+D (Sublime Text, VS Code).

Delete Line

Deletes the current line.

Example:
Ctrl+Shift+K (Sublime Text).

IDE-Specific Features

Visual Studio Code

Multi-Cursor Editing: Alt+Click to add multiple cursors for simultaneous editing.

Column (Box) Selection: Shift+Alt+Drag to select text in a column.

Find and Replace: Ctrl+F for find, Ctrl+H for replace, supports regex.

Format Document: Shift+Alt+F to format the entire document.

Sublime Text

Multi-Selection: Ctrl+Click to add multiple selections for simultaneous editing.

Column Selection: Ctrl+Shift+Up/Down to select text in a column.

Find and Replace: Ctrl+F for find, Ctrl+H for replace, supports regex.

Reindent Lines: Edit -> Line -> Reindent to fix indentation.

IntelliJ IDEA

Column Selection Mode: Alt+Shift+Insert to toggle column selection mode.

Multiple Cursors: Alt+Click to create multiple cursors.

Find and Replace: Ctrl+F for find, Ctrl+R for replace, supports regex.

Reformat Code: Ctrl+Alt+L to reformat the code.