Developer utilities: JavaScript regex syntax, Sourcetree and TablePlus shortcuts

These three tools handle the work around the code rather than the code itself: regular expressions are a pattern language for finding text, Sourcetree is a desktop client for Git and TablePlus one for databases. The regex section follows JavaScript as MDN documents it, from classes such as [xyz] and alternation with x|y through lookarounds like x(?=y) and named groups like (?<Name>x) to the flags.

Each tool keeps its own section with a table, notes and a dated source, and the columns follow that source. Sourcetree pairs Windows keys from version 3.4.32 with Mac keys from version 4.2.19, both read from Atlassian's installers, and ends with commands that exist only on a Mac. TablePlus has a single Mac column because its documentation prints Mac keys only and tells Windows users to press Control where a key uses Command.

Not covered here: POSIX grep and sed regex syntax, the macOS editing and window commands in Sourcetree, and Git itself, which has a page of its own, as do the database clients DBeaver and DataGrip.

3 tools, 179 rows. Edited by Jay.

Regex (Regular Expressions) 62

Regular expression syntax as JavaScript defines it and MDN documents it, where x and y stand for any sub-pattern and n and m for counts. The table runs from character classes, escapes, anchors and word boundaries to capturing and named groups, backreferences, lookahead and lookbehind, greedy and lazy quantifiers and the flags.

Character classes 12

Without the u or v flag, \p and \P are not property classes at all: they simply match the letters p and P.

PatternWhat it does
.Any characterSkips line terminators unless the s flag is set; inside square brackets it stands for a literal dot.
\dDigit characterEquivalent to the class [0-9], so only the ten Arabic numerals count.
\DNon-digit characterMatches anything \d would reject, the same as [^0-9].
\wWord characterCovers A to Z in both cases, 0 to 9 and the underscore, so an accented letter such as É is left out.
\WNon-word characterThe opposite of \w, so punctuation, spaces and accented letters such as É match it.
\sWhitespace characterAlso counts tabs, line breaks, form feeds and other Unicode space characters, not only the plain space.
\SNon-whitespace characterMatches any single character that \s would not, letters and punctuation included.
[xyz]Character classMatches one of the listed characters; a hyphen placed first or last in the brackets is taken literally.
[a-c]Character rangeA hyphen between two characters covers the whole range, so [a-d] equals [abcd].
[^xyz]Negated character classA caret right after the opening bracket inverts the class, so any character not listed matches.
\p{UnicodeProperty}Unicode property classSelects characters by a Unicode property such as emoji or Han script; needs the u or v flag.
\P{UnicodeProperty}Negated Unicode propertyThe complement of \p: any code point that lacks the named property, again only with u or v.

Escapes 13

PatternWhat it does
\tHorizontal tab
\rCarriage return
\nLine feed
\vVertical tab
\fForm feed
[\b]Backspace characterWorks only inside square brackets; a bare \b is the word-boundary assertion instead.
\0NUL characterNever put a further digit straight after it in the pattern.
\cXControl characterThe X is any letter, upper or lower case, so \cM\cJ finds a carriage return followed by a line feed.
\xhhHex character codeTakes exactly two hex digits giving the code of the character.
\uHHHHUnicode escapeTakes exactly four hex digits and stands for one UTF-16 code unit.
\u{H…H}Code point escapeAccepts one to six hex digits and works only in Unicode-aware mode, that is with u or v.
\Escape next characterMakes a special character literal, as \* for an asterisk, or gives a plain letter a special meaning, as in \b.
\\Literal backslashA backslash escapes itself, so two in a row stand for one backslash in the text.

Anchors and boundaries 7

MDN marks \A, \z and \Z as experimental, so check browser support before relying on them.

Python 3.14 reads \Z as a synonym for \z, the very end of the string, with no allowance for a trailing newline.

PatternWhat it does
^Start of inputWith the m flag it also matches just after each line break; at the start of brackets it negates instead.
$End of inputWith the m flag it also matches right before each line break, so it can anchor every line.
\bWord boundaryZero-width: it marks the spot between a word character and a non-word character, and consumes nothing.
\BNot a word boundaryMatches between two word characters or two non-word characters, as in the middle of a word.
\AStart of stringMatches only at the very beginning, even with the m flag; works only in Unicode-aware mode.
\zEnd of stringMatches only at the very end, even when m is on; again Unicode-aware mode only.
\ZEnd before final newlineLike \z, but a single trailing line break, a line terminator or \r\n, may follow.

Groups and lookarounds 12

Python's re module writes a named group as (?P<name>...) and refers back to it with (?P=name).

PatternWhat it does
(x)Capturing groupRemembers the match; groups are numbered in the order of their opening parentheses.
(?<Name>x)Named capturing groupPuts the match on the result's groups property under that name, so code can read it by name.
(?:x)Non-capturing groupGroups part of a pattern without storing it, so it never shows up among the numbered results.
\1Numbered backreferenceMatches the same text that group 1 captured; any positive number points to that group.
\k<Name>Named backreferenceRepeats the text that the group with this name captured earlier in the match.
(?flags:x)Inline flag modifierTurns flags on for the enclosed part only; just i, m and s may be used.
(?flags-flags:x)Inline flag removalFlags before the hyphen are switched on and those after it off, for the enclosed part only.
x|yAlternationEither side may match; wrap it in a group such as (?:x|y) to use it inside a longer pattern.
x(?=y)LookaheadMatches x only when y comes next; y itself is not part of the match.
x(?!y)Negative lookaheadMatches x only when y does not come next, as in \d+(?!\.) for a number without a decimal point.
(?<=y)xLookbehindMatches x only when y comes right before it; y stays out of the match.
(?<!y)xNegative lookbehindMatches x only when y does not come before it, as in (?<!-)\d+ for a number with no minus sign.

Quantifiers 10

PatternWhat it does
x*Zero or moreRepeats the preceding item as often as possible, including not at all.
x+One or moreSame as x{1,}: the preceding item has to appear at least once.
x?Zero or oneMakes the preceding item optional; placed after another quantifier it makes that quantifier lazy.
x{n}Exactly n timesNeeds that exact count in a row: a{2} skips the lone a in candy but takes both in caandy.
x{n,}At least n timesLeaves the upper limit open, so x{1,} behaves like x+.
x{n,m}Between n and m timesBoth bounds are included and m must be at least n, as in a{1,3}.
x*?Lazy zero or moreTakes as few repetitions as it can, where plain x* takes as many as possible.
x+?Lazy one or moreNeeds at least one repetition but, unlike the greedy x+, settles for the fewest it can.
x??Lazy optionalThe lazy version of x?: it tries the item zero times before trying it once.
x{n,m}?Lazy counted repeatNon-greedy form that settles for as few as n repetitions instead of reaching for m.

Flags 8

PatternWhat it does
dMatch indicesRecords the positions of substring matches in the result; read back through the hasIndices property.
gGlobal searchLooks for matches throughout the whole string rather than just one; shows up as the global property.
iIgnore caseTreats upper and lower case as equal; reflected in the ignoreCase property.
mMultiline anchorsLets ^ and $ match at every line start and end, not just the ends of the string.
sDot matches newlinesLets the dot match line breaks too; the matching property is called dotAll.
uUnicode modeReads the pattern as Unicode code points and turns on escapes such as \u{H…H} and \p{…}.
vUnicode sets modeUpgrade of the u flag with extra Unicode features; reported by the unicodeSets property.
ySticky searchAnchors each attempt to the current position in the string; the property is called sticky.

The tokens

. matches any single character except (usually) a newline. \d, \w and \s match a digit, a word character (letters, digits, underscore) and whitespace; their capitals match the opposite. [xyz] is a character class — any one of those — and [a-c] a range, with [^xyz] for "anything but". x*, x+ and x? repeat the preceding item zero or more, one or more, and zero or one times, and {2,5} sets a range of counts. (x) captures for later reference and x|y is alternation, which binds loosely — (cat|dog)s needs the parentheses.

Anchors and greed

^ and $ anchor to the start and end of the input (or of each line, with the m flag), and forgetting them is how \d+ "matches" a number inside a word. Repeats are greedy — they take as much as possible — so ".*" across "a" and "b" matches the whole span; the lazy form .*? stops at the first closing quote. Escape a metacharacter with a backslash to match it literally: \. for a dot, \( for a parenthesis.

Flavours

The table follows JavaScript. Basic grep and sed need backslashes before +, ?, |, ( and ) unless run with -E; Perl-style engines (Python, JavaScript, PCRE, ripgrep) use them bare. Lookarounds ((?=…), (?<!…)) and named groups are missing from POSIX tools, and lookarounds even from some Perl-style engines, ripgrep's default one among them. Python spells a named group (?P<name>…). When a pattern works in one tool and not another, the flavour is the first suspect.

How do I match a literal dot, asterisk or parenthesis?

Put a backslash in front of it: \ turns a special character into a plain one, so \* matches an asterisk, \. a dot and \( a parenthesis. A backslash itself is written \\. Wrapping the character in a class, as in a[*]b, works too.

Why does .* match far more than I wanted?

Quantifiers are greedy and take as many repetitions as they can. Add a question mark to make them lazy — x*?, x+? — so they stop at the fewest repetitions that still give a match.

How do I name a capturing group and match it again later?

Write the group as (?<Name>x) and refer back to it with \k<Name>; in JavaScript the captured text also lands on the result's groups property. Python's re module uses (?P<name>…) and (?P=name) instead.

Source: MDN Web Docs — Regular expression syntax cheat sheet (JavaScript Guide). Checked row by row on .

4 more source pages

Sourcetree 55

Sourcetree is Atlassian's Git client for Windows and Mac, and its table sets the Windows keys beside the Mac ones. It covers repository tabs and views, commit, stash, push, pull, fetch, branch, merge and tag, file actions such as external diff, log and blame, the bookmarks list and the Mac-only commands.

Repositories and tabs 9

The View menu shows Ctrl + Tab for Next Tab, but the window's key-binding table of Sourcetree 3.4.32 assigns Ctrl + Tab to the previous tab and Ctrl + Shift + Tab to the next one.

ActionWindowsMac
Clone / NewCtrl+NCmd+N
Open repositoryCtrl+OCmd+O
Close tabCtrl+WCmd+W
New tabCtrl+T—
Next tabCtrl+Tab—
Previous tabCtrl+Shift+Tab—
Toggle bookmarks sidebarCtrl+B—
Options (Preferences on Mac)Ctrl+,Cmd+,
Exit SourcetreeAlt+F4Cmd+Q

Views and refresh 5

ActionWindowsMac
Refresh repositoryRuns a manual full refresh rather than waiting for the automatic one.F5Cmd+R
File Status viewLists modified, new, deleted and untracked files with checkboxes and hunk buttons for staging.Ctrl+1Cmd+1
History viewShows the commit graph with branches, tags and tracked remote branches; the knowledge base calls it Log View.Ctrl+2Cmd+2
Search viewCtrl+3Cmd+3
Refresh remote statusRechecks which commits are incoming from or outgoing to the remote.Alt+Shift+RCtrl+Option+R

Git management 14

ActionWindowsMac
Commit AllCtrl+Shift+CCmd+Option+Shift+C
Commit SelectedCommits only the files picked in the file list rather than all changes.Alt+Shift+CCmd+Option+C
Revert changesOpens the Revert dialog, the same one the toolbar button shows.Ctrl+Shift+RCmd+Shift+R
Stash changesCtrl+Shift+SCmd+Shift+S
Push to remoteCtrl+Shift+PCmd+Shift+P
Pull from remoteCtrl+Shift+LCmd+Shift+L
Fetch from remoteCtrl+Shift+FCmd+Shift+F
Check outCtrl+Shift+U—
Create branchCtrl+Shift+BCmd+Shift+B
Merge branchCtrl+Shift+MCmd+Shift+M
Add or remove tagCtrl+Shift+TCmd+Shift+T
Git-flow next actionAlt+Shift+FCmd+Option+F
Create pull requestAlt+Shift+PCmd+Option+P
Repository settingsCtrl+Shift+,Cmd+Shift+,

Working with files 10

On Windows both Revert and Discard Selected show Ctrl + Shift + R; the key binding itself runs Discard Selected.

ActionWindowsMac
Open selected filesCtrl+Shift+OCmd+Shift+O
Open in TerminalThe terminal starts in the selected file's folder, or in the repository root when nothing is selected.Alt+Shift+TCtrl+Cmd+T
External DiffOn Windows the same key starts the external merge tool when the file has conflicts.Ctrl+DCmd+D
Add to version controlCtrl+Shift++Cmd+Shift+=
Remove from version controlCtrl+DeleteCmd+Backspace
Unstage from indexCtrl+Shift+-Cmd+Shift+-
Add/Remove all filesCtrl+Alt+Shift++Cmd+Option+Shift+=
Discard selected filesWorks on the current selection without the full Revert dialog; on Windows it shares its key with Revert.Ctrl+Shift+RCmd+Option+R
Log of selected fileAlt+Shift+LCmd+Option+L
Blame (Annotate) selectedAlt+Shift+BCmd+Option+B

Commit box and dialogs 2

ActionWindowsMac
Confirm the commitCtrl+Enter—
Close a message dialogEsc—

Bookmarks list 4

ActionWindowsMac
Rename bookmark or folderF2—
New bookmark folderCtrl+Shift+N—
View remote repositoryOnly in the bookmarks list; in an open repository the same key refreshes remote status.Alt+Shift+R—
Delete selected bookmarkDelete—

Mac only 11

ActionWindowsMac
Commit changes—Cmd+Shift+C
Show sidebar—Cmd+Shift+K
Filter in sidebar—Cmd+Shift+J
Show command history—Ctrl+Cmd+W
Enter full screen—Ctrl+Cmd+F
Repository details—Cmd+Shift+I
Update to revision—Cmd+Option+U
View repository online—Cmd+Shift+W
Quick Look previewPreviews the selected file and works in the flat, tree and column file views.—Space
Show repository browser—Cmd+0
Remote hosted repositories—Cmd+Shift+H

The daily loop

Ctrl + 1 opens the File Status view, where you stage files with the checkboxes or the hunk buttons; Ctrl + Shift + C starts a commit and Ctrl + Enter confirms it on Windows. Pushing is Ctrl + Shift + P, pulling Ctrl + Shift + L; Ctrl + Shift + F fetches, which updates the remote branches shown in the graph without touching your working copy, the safe way to see what changed upstream before deciding to pull. F5 refreshes the view when Sourcetree has not noticed a change made in the terminal. On a Mac the same verbs use Cmd + Shift (Cmd + Shift + P, Cmd + Shift + L), but Commit All is Cmd + Option + Shift + C.

Branches and tabs

Ctrl + Shift + B opens the Branch dialog. On Windows each repository opens in its own tab: Ctrl + T adds a tab, Ctrl + Tab moves between them and Ctrl + W closes the current one; Ctrl + B shows or hides the bookmarks sidebar. Ctrl + 2 switches to the History view and Ctrl + 3 to the Search view (Cmd + 2 and Cmd + 3 on a Mac).

When the GUI is not enough

Sourcetree exposes most of git but not all of it; interactive rebase is there, and anything with unusual flags goes through the terminal: Alt + Shift + T (Ctrl + Cmd + T on a Mac) opens one in the repository folder. Custom actions can run your own git commands from the menu. Sourcetree picks up changes made in the terminal on the next refresh, so mixing the two is normal.

Why does Ctrl + Shift + C say Commit All in Sourcetree's menu?

Sourcetree splits committing into Commit All, which starts with every modified file (or the staged ones when you use staging), and Commit Selected, which takes only the files you picked. On Windows they are Ctrl + Shift + C and Alt + Shift + C; on a Mac Cmd + Option + Shift + C and Cmd + Option + C, while Cmd + Shift + C is the plain Commit command.

Which key discards changes to just the selected files?

On a Mac it is Cmd + Option + R (Revert/Reset Selected); Cmd + Shift + R opens the full Revert dialog instead. Sourcetree for Windows shows Ctrl + Shift + R for both menu entries, and the key runs Discard Selected.

Source: Atlassian Sourcetree for Windows 3.4.32: main menu and key bindings (read from the official installer). Checked row by row on .

5 more source pages

TablePlus 62

TablePlus is a database client, and its section lists the Mac keys printed on the official Shortcut Keys page: connections, tabs and panes, committing or discarding staged edits, the SQL query editor with multiple cursors, the data grid, the structure view and the row and column filters.

Connections and app 9

The TablePlus documentation prints macOS keys only; its getting-started guide says to use Control wherever these keys use Command on Windows.

ActionMac
New connectionOpens a new window, from which the connection you want is then opened.Cmd+N
Switch connectionLists saved connections; double-clicking one opens it in a new workspace tab of the same window.Cmd+Shift+K
Switch databaseLists the databases on this connection; double-clicking one opens it in a new workspace.Cmd+K
Open anythingQuick open a table, view, or function by name.Cmd+P
New SQL ViewerCmd+Shift+O
Plugin managerSame as Plugin > Manage Plugins, where the SQL Formatter Plugin is installed.Cmd+L
Toggle console logCmd+Shift+C
Open preferencesPreferences hold the Keymap tab, where any default binding can be reassigned.Cmd+,
Quit TablePlusCmd+Q

Tabs and panes 10

The Editor Basics page gives Cmd + . for cancelling a long-running query through the Process List, while the shortcut table names it Run custom script.

ActionMac
New tabCmd+T
Close tabCmd+W
Go to left tabCmd+[
Go to right tabCmd+]
Go to tab by numberCmd+Number
Go to left paneCmd+Shift+[
Go to right paneCmd+Shift+]
Split pane horizontallyWorks in the query editor, which is then shown as two panes.Cmd+Shift+D
Reload workspaceRun it after importing data so the open table is read again.Cmd+R
Run custom scriptCmd+.

Committing changes 5

ActionMac
Commit changesGrid and structure edits stay local until this sends them to the database server.Cmd+S
Preview changesShows the SQL generated for uncommitted GUI edits, like the Code review button.Cmd+Shift+P
Discard changesCancels uncommitted GUI edits; statements already run from the query editor are not affected.Cmd+Shift+Delete
Undo last actionCmd+Z
Redo last actionCmd+Shift+Z

Query editor 10

ActionMac
Open query editorThe editor opens with the most recently used script already loaded.Cmd+E
Execute queryRuns the selected query; when no editor is open, the same keys open one.Cmd+Return
Run AllExecutes every selected statement; separate the statements with semicolons.Cmd+Shift+Return
Open SQL fileCmd+O
Save SQL asCmd+Shift+S
Toggle line commentCmd+/
Beautify SQLReformats the selected queries with the built-in formatter so they are easier to read.Cmd+I
Uglify SQLThe mouse route is the dropdown next to the Beautify button.Cmd+Shift+I
Indent selected SQLThe shortcut table lists this one for SQL Viewer windows as well as query tabs.Cmd+IorCtrl+I
Run SQL Format pluginNeeds the SQL Formatter Plugin, installed first from the plugin manager.Ctrl+I

Multiple cursors 6

ActionMac
Add cursor at click pointCmd+Click
Add cursor aboveCtrl+Shift+Up
Add cursor belowCtrl+Shift+Down
Select next occurrenceWith nothing highlighted, it first picks up the word under the cursor.Cmd+D
Select all occurrencesPuts a cursor on every match at once instead of one by one.Cmd+Ctrl+G
Exit multiple cursorsEsc

Data grid 10

Defaults can be changed in Preferences, Keymap tab: click a shortcut value and type the new keys, or clear it to restore the default.

ActionMac
Edit cell inlineThe new value is written to the server only after a commit.Double-click
Toggle row detailsShows the selected row in the right sidebar, where several selected rows can be edited in bulk.Space
Quick LookShows a JSON or BLOB cell in a larger popup for easier reading.Middle-click
Quick edit menuOption+Click
Move editing focusTab
Insert rowWorks while a row is selected; the new row is saved only on commit.Cmd+I
Duplicate rowCopies the selected rows as new rows that still need a commit.Cmd+D
Copy rowsCmd+C
Paste rowsPasting copied rows is another way to duplicate them in the table.Cmd+V
Delete selected rowsLike other grid edits, the deletion reaches the server only on commit.Delete

Table structure 5

ActionMac
Open structure viewSwitches from the data grid to the table's columns; its Definition button shows the CREATE TABLE.Cmd+Ctrl+]
Back to data viewThe Data button below the structure view does the same.Cmd+Ctrl+[
Add columnWorks in the structure view with a column selected; commit to apply it.Cmd+I
Delete columnUsed in the structure view; the column is dropped only after a commit.Delete
Delete tableSelect the table in the left sidebar first; nothing is dropped until you commit.Delete

Filters 7

ActionMac
Open row filterTablePlus turns the filter conditions into a SELECT with a WHERE clause for you.Cmd+F
Open column filterLimits the grid to the ticked columns; Clear and then Apply brings every column back.Cmd+Option+F
Apply filterApplies only the selected filter row, whose button then reads Applied.Return
Apply checked filtersApplies every filter whose checkbox is ticked, like the Apply all button.Cmd+Return
Duplicate filterThe plus button beside a filter row does the same.Cmd+I
Remove filterThe minus button beside a filter row does the same.Cmd+Shift+I
Close filtersHides the filter bar, the same as clicking the Filters button again.Esc

Connections and tabs

Cmd + N opens a new window for a connection — connections can carry a colour and a tag such as Local, Staging or Production — and Cmd + T opens an empty tab, so several tables and queries stay side by side. Cmd + K and Cmd + Shift + K switch database or connection, opening the choice in a new workspace tab of the same window by default. Cmd + W closes a tab and Cmd + R reloads the workspace. Cmd + , opens preferences, including the Keymap tab where bindings can be changed.

Finding and filtering

Cmd + P is Open Anything: type part of a table, view or function name and pick it from the suggestions, which replaces scrolling a sidebar with hundreds of tables. Cmd + F opens the row filter on a table view, where conditions on columns are built without writing SQL and can be combined; Cmd + Option + F chooses which columns are shown, and Esc closes the filter bar again.

Queries and staged edits

Cmd + E opens the query editor with the most recent script, Cmd + Return runs the selected query and Cmd + Shift + Return runs all selected statements. Data edits made in the grid or structure view — changed cells, inserted rows, deletions — are not sent to the database until Cmd + S commits them. Cmd + Shift + P shows the SQL that will run and Cmd + Shift + Delete discards the pending changes. Safe mode, switched with the lock icon at the top of the window, sets how you are warned before a query runs.

Do these TablePlus shortcuts work on Windows?

The TablePlus documentation lists macOS keys only. Its getting-started guide says to use Control on Windows wherever a shortcut uses Command.

Why do my edits in the TablePlus grid not appear in the database?

Changes made in the data grid or structure view are staged. Press Cmd + S to commit them, Cmd + Shift + P to review the generated SQL first, or Cmd + Shift + Delete to discard them.

How do I switch between a table's data and its structure?

Cmd + Ctrl + ] opens the structure view and Cmd + Ctrl + [ goes back to the data view; the Structure and Data buttons at the bottom of the table do the same.

Can I change TablePlus shortcuts?

Yes. Open preferences with Cmd + ,, go to the Keymap tab, click a shortcut value and type the new keys; clearing a value restores the default.

Source: TablePlus Docs — Shortcut Keys. Checked row by row on .

9 more source pages

Questions

Does the regex table also work in Python?

Mostly. The table follows JavaScript as MDN documents it, and Python's re module reads most rows the same way. The notes mark where it differs: Python writes a named group as (?P<name>...) instead of (?<Name>x) and refers back with (?P=name) instead of \k<Name>, and Python 3.14 reads \Z as the very end of the string, with no allowance for a trailing newline. POSIX grep and sed syntax is not covered.

Are Sourcetree's Mac keys just the Windows keys with Cmd?

For most Git commands, yes: push is Ctrl + Shift + P on Windows and Cmd + Shift + P on a Mac, and pull and fetch follow the same pattern. Some do not. Commit All is Ctrl + Shift + C on Windows but Cmd + Option + Shift + C on a Mac, where Cmd + Shift + C is a separate Commit command; refresh is F5 on Windows and Cmd + R on a Mac; and Log, Blame and Commit Selected move from Alt + Shift to Cmd + Option.

Why does Cmd + I do different things in TablePlus?

The documentation assigns Cmd + I by context. In the data grid it inserts a row, in the structure view it adds a column and in the filter bar it duplicates a filter; in a SQL tab the shortcut table gives it both to Beautify and to indenting the selected SQL. A new row or column reaches the database only when Cmd + S commits it.

Sources and checks

Each tool on this page keeps its own source line under its table. The documented lists of these 3 tools are short enough to read together, so they share this page; each keeps its own section, and its old address redirects to that section.

Found a wrong or missing key? Tell us and it gets checked against the source. How we verify describes the process and its limits.