Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Prism SearchNew to Visual Studio Code? Get it now.
Prism Search

Prism Search

uta-orange

|
18 installs
| (0) | Free
Manage multiple search terms in independent search boxes and highlight them simultaneously in different colors.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

🌈 Prism Search

Manage multiple independent search terms, each highlighted in its own color, across the current file or the whole workspace.


✨ Key Features

  • Multiple independent search boxes — each with its own term, color, and options (case/whole word/regex)
  • Simultaneous multi-color highlighting — across the active editor and every visible split pane at once
  • Match navigation — step through each box's matches with ▲▼ or Enter / Shift+Enter
  • Workspace-wide search & replace — with optional ripgrep support for speed and automatic .gitignore handling
  • Replace, per box — including workspace-wide Replace All with a confirmation dialog and one-click Undo
  • Find in Selection — restrict a box's matches to your current selection, even while workspace-searching (see below)
  • Save results — write a workspace-search box's results to a text file, one path:line: text line per matching line
  • Search history & quick actions — reuse recent terms, or grab the word under your cursor via keybinding or icon

🔍 Using It

Highlighting

  • Type into a search box to highlight matches, in that box's color, in the active editor. Split panes are all highlighted too (the inactive pane is shown dimmer)
  • + Add Search Box adds an empty box with the next color in the palette
  • Aa / ab / .* toggle Match Case / Whole Word / Regex
  • The eye icon hides the highlight without stopping the search; ✕ removes the box

Navigating

  • ▲▼, or Enter / Shift+Enter in the input, jump to the next/previous match, starting from the cursor and wrapping around
  • The match count (1/12) always reflects where "next" will actually land

Workspace search

  • Click the folder icon 📁 to search the whole workspace instead of just the active file. Results appear as a clickable file/line list below the box
  • The "Include" field filters which files are searched, by name/path (plain text or globs, comma-separated):
    • Commas inside {} / [] are kept, so *.{ts,tsx} works as a single pattern
    • A glob without /, such as *.ts, matches at any depth, the same as VS Code's own search
    • An entry starting with ./, or an absolute path inside the workspace, is anchored to the workspace root: ./src means the src folder at the root and everything under it, not every path that merely contains "src". . means everything. In an entry without / such as ./*.ts, the ./ has no effect and it still matches at any depth
    • With several workspace folders, such an anchored entry applies to each folder, so a path that exists in more than one folder matches in all of them
    • On Windows, a plain entry written with backslashes, such as src\utils, is read as src/utils
    • With ripgrep, files excluded by .gitignore stay excluded even when Include is set
  • Results are sorted by proximity to your current file
  • The 🔄 button next to the Include field re-runs the workspace search with the same settings — handy after editing files, since the search is not re-run automatically when files change
  • While a workspace search is running, the previous result list stays visible (dimmed) and the match badge shows the current file's position/count with a trailing … (e.g. 2/7…), instead of going blank. Enter and ▲▼ keep working on the current file's matches during that time, and switch to workspace-wide navigation once the search finishes. With the built-in scanner, matches appear progressively together with a scanned/total files indicator; for very large projects, enabling ripgrep (prismSearch.workspaceSearch.useRipgrep) is much faster
  • Combining with Find in Selection: turn on the selection icon while workspace-searching to restrict the current file's highlighting, match count/navigation, and Replace All to your selection. The file/line list below stays unrestricted (it still shows every match in every file) — only the badge, ▲▼, and what actually gets rewritten in your active file are scoped to the selection

Replace

  • Click the replace icon to reveal Replace / Replace All / Undo
  • Current file: Undo reverts whichever replace you just did (Replace or Replace All) — but only while you haven't touched that file again since. The Undo button is greyed out except right after a replace; make any other edit (even an unrelated one) and it disables itself rather than risk undoing the wrong thing. If you need to undo after that, use Ctrl+Z instead
  • Whole workspace: only Replace All is available, with a confirmation dialog showing the affected count. Since each file is a separate edit, Ctrl+Z only undoes the file you're in — use the Undo button to revert the whole batch at once. It is one-shot: it stays available until you use it, even if you keep editing, and before reverting it checks each location — any occurrence whose text has changed since the replace is skipped and reported
  • Regex mode supports $1, $2, $0 (same as $&), $$ in the replacement text, and \n (newline), \t (tab) and \\ (a single backslash), the same as VS Code's own replace. Any other \x is kept as typed
  • Regular expressions are compiled with the Unicode flag when possible, so \p{L} and \u{1F600} work and . / [^a] treat an emoji as one character. Needless escapes of punctuation that Unicode mode rejects (such as \-, \_, \@ or \# outside a character class) are accepted as-is, so mixing them with \p{L} or emoji works. Patterns that are still not valid in Unicode mode automatically fall back to the non-Unicode mode, so existing patterns keep working
  • Regular expressions are matched line by line, the same as VS Code's own search, so \s+$ (trailing whitespace) or [^,]+ never swallow line breaks. Only a pattern that contains \n, \r or \W (or a literal line break in the search text) is matched across lines — so a lazy catch-all such as [\s\S]*? no longer spans lines on its own; write the line break explicitly, e.g. start\n(.*\n)*?end (this is how VS Code's own search behaves too). In CRLF files, \n (and \W) in such a pattern matches a whole line break (\r\n) as one unit, the same as VS Code's own search, so foo\nbar finds foo, a CRLF and bar; a pattern that contains \r (e.g. \r\n or \r?\n) is matched against the file's raw text instead. In workspace search, the empty line after a file's final newline is not counted as a line (same as ripgrep), so $ → ; does not add a stray line at the end of every file
  • Empty matches work like in VS Code's own search: ^, $, \b and lookarounds match a position without consuming text, so Replace / Replace All can insert text — e.g. search ^ and replace with // to comment out every line, or search $ and replace with ;. An empty match is highlighted as the character to its right (for ^, the first character of the line), or the character to its left when there is none (for $, the last character); on a completely empty line (no character to paint) a one-character-wide mark is drawn at the start of the line instead. An empty match right where the previous match ended (e.g. the empty match after aa when searching a* in aab) is not reported, the same as ripgrep. Each empty match counts as one match, so it also counts toward the 5000-per-box limit

Saving results

  • For workspace-search boxes, the save icon next to the "search again" button (in the filter row) writes the results to a text file: a header (date, workspace, query, options, Include), then one line per matching line as path:line: the whole line. If a line has several matches it is listed once, and the header gives the match, line and file counts
  • The icon is enabled only while the box's search results are shown — not while a search is running (including right after you press "search again" or change the search) and not when there are no results. It does not appear for current-file boxes
  • The results are saved in the order shown. The save dialog proposes prism-search_<workspace>_<search term>.txt (characters that file names can't contain become _, and long names are shortened) and starts in the folder you used last. A button in the confirmation message opens the saved file
  • The lines are read again from the files, so you get the whole line instead of the shortened preview; extremely long lines are cut to about 2,000 characters around the match. If a file was edited after the search (so the line no longer matches what was found), the shortened preview from the results list is used for that line and the header says so
  • If the results are incomplete — the result or file limit was reached, files were skipped because a regular expression was too slow, or files over the size limit are not searched — the header says so

Other shortcuts

  • Ctrl+Alt+F adds the selection (or word under cursor) as a new search term in a newly created box (the bottom box is never reused, even if it's empty), then moves focus to that box's input with the caret at the end of the text (nothing is selected) — so you can press Enter right away. If the caret was already on a match (the word you just added), the first Enter goes straight to the next one. With no selection or word under the cursor, it adds a new empty box and focuses it so you can just start typing
  • Prism Search: Add Search Box (Ctrl+Alt+F, the Command Palette, and the editor's right-click menu, which shows the shortcut) uses the selection / word at the cursor if there is one, otherwise it adds an empty box — always a new one, never an existing empty box. The "Add Search Box" button at the bottom of the panel and the + in the title bar (Prism Search: Add Empty Search Box) always add a new empty box and focus it
  • Prism Search: Add Search Box Without Opening Sidebar (Ctrl+Alt+Shift+F, the Command Palette, and the editor's right-click menu) adds the selection / word at the cursor as a new box just like the command above, but never opens the sidebar and keeps the focus in the editor — handy for adding words to the highlights one after another while you keep working. The word is highlighted right away and a short message appears in the status bar; the box is waiting in the sidebar the next time you open it (also after restarting VS Code). With no selection or word at the cursor it adds nothing, because an empty box wouldn't be visible
  • While typing in a box (search, replace, or include field): Ctrl+Alt+C toggles Match Case, Ctrl+Alt+W Whole Word, Ctrl+Alt+R Regex (Cmd+Option+C/W/R on macOS). In workspace search, Enter / ▲▼ / clicking a result open the match in the editor but keep focus in the sidebar, like VS Code's own search view. Esc returns focus to the editor
  • The target icon on any box does the same, but always fills that specific box
  • The history icon shows recently used terms for this workspace
  • The color dot opens a color picker; a reset button appears once you've changed it from its default
  • The selection icon turns on Find in Selection, restricting that box to your current selection (works together with workspace search, see above). The 🔄 icon that appears re-captures the boundary from your current selection; the boundary itself is saved and restored across restarts, and keeps tracking correctly through further edits to the file. If you select whole lines (the selection ends at the start of the next line, e.g. with Shift+Down), the range stops at the end of the last selected line, so the following line is left alone — like VS Code's own Find in Selection. Text inserted exactly at either edge of the range (for example by Replace All) becomes part of it, so you can keep working on the same selection (e.g. comment lines out with ^ → // , then remove the comments with ^// → empty)
  • A toolbar below the title bar toggles Visibility / Workspace Search / Match Case / Whole Word / Regex for all boxes at once
  • Search box state is saved per workspace and restored on restart

⚡ Ripgrep Integration

Workspace search uses a built-in scanner by default. Turn on prismSearch.workspaceSearch.useRipgrep to use rg (ripgrep) instead, if it's installed and on your PATH — faster, and respects .gitignore automatically:

{
  "prismSearch.workspaceSearch.useRipgrep": true,
  // Optional: full path to rg (leave empty to look it up on PATH; "~" is allowed)
  "prismSearch.workspaceSearch.ripgrepPath": "~/.local/bin/rg",
  // Max number of workspace search results (default 20000, 0 = unlimited)
  "prismSearch.workspaceSearch.maxResults": 20000,
  // Built-in scanner only: max files read per search, nearest to the active file first (default 2000, 0 = unlimited)
  "prismSearch.workspaceSearch.maxFiles": 2000,
  // Files larger than this are skipped, by both engines (default 2, range 0.1-100)
  "prismSearch.workspaceSearch.maxFileSizeMB": 2,
  // Max time for one regular-expression run, in ms (default 1000, range 100-10000)
  "prismSearch.regexTimeoutMs": 1000
}

This extension doesn't bundle ripgrep. If rg can't be found, or a specific pattern isn't supported (e.g. lookahead/lookbehind), it falls back to the built-in scanner for that search — turning the setting on never breaks anything. When this happens for a reason specific to the search (for example, a lookahead pattern), a notification explains why; each reason is shown only once per window. (Search text that contains a line break, e.g. a multi-line selection, is always handled by the built-in scanner, because ripgrep searches line by line.)

rg is looked up in this order: the path in prismSearch.workspaceSearch.ripgrepPath (if set), then your PATH. Changing ripgrepPath (or useRipgrep) takes effect right away — no window reload needed. If you fix your PATH or install ripgrep afterwards, fully restart VS Code (all windows), because the extension host only sees the environment VS Code was started with. For safety, PATH entries that are inside the opened workspace folder are ignored (for example, if you open your home folder, ~/.local/bin is skipped) — set ripgrepPath in that case. ripgrepPath can be set in User, Remote and Workspace settings (precedence: Workspace > Remote > User): set it once in User settings to use it everywhere, or override it only in the Remote settings. In a remote window (WSL, SSH, Dev Containers) the path must exist on the remote machine; if a local path from User settings doesn't, you'll get the "not a usable ripgrep executable" warning and PATH is searched instead — set ripgrepPath in the Remote settings then. In an untrusted workspace the workspace-level value is ignored.


📁 Workspace Search Exclude Settings

// .vscode/settings.json (per-workspace) or User Settings
{
  "prismSearch.workspaceSearch.excludeGlobs": [
    "**/node_modules/**",
    "**/.git/**",
    "**/dist/**",
    "**/generated/**"
  ],
  "prismSearch.workspaceSearch.respectFilesExclude": true
}
  • excludeGlobs replaces the default exclude list entirely (extend it yourself if you still need the defaults)
  • .git (folders and files) is always excluded from workspace search and Replace All, regardless of excludeGlobs
  • respectFilesExclude (on by default) also excludes anything matched by VS Code's own files.exclude / search.exclude
    • Only entries set to true are used. An entry with a condition, such as { "**/*.js": { "when": "$(basename).ts" } }, is not applied, because the condition can't be evaluated here (otherwise every .js file would be hidden from search and Replace All)

⚙️ Other Settings

{
  // Highlight inactive split panes too (default: true)
  "prismSearch.highlightInactiveEditors": false,

  // Defaults for newly created search boxes
  "prismSearch.newSearch.caseSensitive": false,
  "prismSearch.newSearch.wholeWord": false,
  "prismSearch.newSearch.regex": false,
  "prismSearch.newSearch.scope": "file" // or "workspace"
}

⚠️ Known Limitations

  • Without ripgrep, .gitignore is not respected (a VS Code API limitation) — customize excludeGlobs instead
  • Workspace search includes hidden files and folders (such as .github or .env) with both the built-in scanner and ripgrep, and Replace All can modify them. Add patterns to excludeGlobs for anything you don't want searched or replaced (.git is always excluded; the defaults also exclude node_modules, etc.)
  • Workspace search reads valid UTF-8 and UTF-16 (with BOM) files directly. Files in other encodings (for example Shift_JIS or EUC-JP) are read through VS Code's own decoding, so they are searchable only if VS Code opens them correctly (set files.encoding or enable files.autoGuessEncoding). When ripgrep is enabled, files where it finds a match on a line that isn't valid UTF-8 are re-read through VS Code's decoding, so those matches are not lost (a search for TODO finds it on lines that also contain Japanese). However, ripgrep itself only matches UTF-8 text, so searching for non-ASCII text inside such files finds nothing with that engine; turn ripgrep off for that
  • Search terms and the search history are stored as plain text in VS Code's workspace storage (on your machine). Avoid typing secrets (API keys, passwords) into a search box if that matters to you
  • If a regular expression takes too long to run (over prismSearch.regexTimeoutMs, 1 second by default, on one file), that file is skipped. The result list then shows how many files were skipped, and the search box shows a warning when the current file is affected
  • Ripgrep's regex engine doesn't support lookahead/lookbehind/backreferences; those patterns fall back to the built-in scanner automatically for workspace search
  • JavaScript (editor highlighting, built-in scanner) and Rust (ripgrep) treat empty iterations inside nested repetitions differently, e.g. ((?:-?)*?)*. For such unusual patterns the matched length can differ between the editor and ripgrep-based workspace results
  • JavaScript and ripgrep also differ in a few character details: \s (JavaScript includes U+FEFF, ripgrep includes U+0085) and . (ripgrep also matches U+2028 / U+2029, JavaScript does not). These rarely matter in practice, but the same search can then give slightly different results with and without ripgrep
  • Workspace search splits lines only at LF (and CRLF). A file that uses a lone CR as its line break (very old Mac files) is split by the editor at every CR, so line numbers in the results can differ from the editor, and Replace All skips the occurrences that no longer match (they are reported as skipped)
  • Workspace search keeps up to prismSearch.workspaceSearch.maxResults matches in total (default 20000, same as VS Code's search.maxResults; set 0 for unlimited — very broad searches can then be slow or memory-hungry). There is no per-file limit. When the limit is hit, the badge shows a + (e.g. 20000+) and the list says the result set only contains a subset. The setting applies from the next search (use the 🔄 re-search button to apply it right away). Both engines skip files over prismSearch.workspaceSearch.maxFileSizeMB (default 2MB, at most 100MB). The built-in scanner additionally looks at prismSearch.workspaceSearch.maxFiles files at most (default 2000, the ones closest to your current file; 0 for unlimited, which can be slow on very large workspaces); ripgrep has no file-count limit. These settings apply from the next search. The result list is virtualized (only the visible rows are drawn), so tens of thousands of matches stay responsive. The Include (filename / glob) field is applied while scanning, so it always filters the full result set — not just the rows currently drawn. Current-file matches are capped at 5000 per box (badge shows 5000+), and Replace All handles up to 5000 matches per run and tells you if more remain — just run it again
  • With ripgrep and an Include filter, matches in .gitignored files are removed after ripgrep returns its results. If ripgrep stops early because the result limit was reached, those files may already have used up part of the limit, so the list can be shorter than the limit suggests. Narrowing the Include field avoids this
  • Workspace search only re-runs when you change the term/options, not when other files change in the background
  • Find in Selection's boundary is fixed to wherever it was captured; it doesn't follow your cursor/selection afterward (use the 🔄 icon to re-capture), though it does track edits to the file itself
  • When combined with workspace search, Find in Selection scopes the badge/navigation/Replace All for your active file, but never touches the file/line list, which always lists every match workspace-wide

🛡️ Regex Mode Security Note

Regex patterns run as real JavaScript RegExp. Nested-quantifier patterns like (a+)+ can cause catastrophic backtracking. This extension blocks the common cases up front (the input gets an orange border; patterns where a required separator makes the end of every repetition unambiguous, such as (\w+\.)+\w+ or ([^,]+,)+, are not blocked), and as a safety net every regex run is also time-limited (1 second by default, configurable with prismSearch.regexTimeoutMs from 100 to 10000 ms — the extension host is blocked while a pattern runs, so keep it modest): if a pattern such as (a|aa)+$ runs too long, it is aborted, marked as unsafe (orange border) and not run again — so it can no longer freeze the extension host. A single run can still take up to that time limit before the abort, so if this concerns you, use literal search instead. These checks don't apply to the ripgrep search itself, since its regex engine is immune to this by design.

Workspace Trust: in an untrusted workspace, the workspace-level values of prismSearch.workspaceSearch.useRipgrep, ripgrepPath, excludeGlobs, respectFilesExclude, maxResults, maxFiles, maxFileSizeMB and regexTimeoutMs are ignored (user-level settings still apply), so a repository can't change how files are scanned.


🛠️ Troubleshooting

Ripgrep doesn't seem to be used, even though I turned it on Make sure rg is installed (check with rg --version in a terminal). If it can't be found, or the path in prismSearch.workspaceSearch.ripgrepPath isn't usable, you'll see a one-time warning notification, and the extension falls back to the built-in scanner (while a built-in scan runs, the status shows scanned/total files, where total is the number of files to scan (at most maxFiles, 2000 by default); with ripgrep it just says "Searching…"). The usual causes and fixes:

  • rg is in a folder inside your opened workspace (e.g. you opened your home folder and rg is in ~/.local/bin) → set prismSearch.workspaceSearch.ripgrepPath to the full path.
  • VS Code was started before rg was installed or added to PATH (the extension host only sees the environment VS Code started with) → fully quit and restart VS Code, or set ripgrepPath.
  • rg is only a shell alias or function, not an executable file on PATH (check with which rg / Get-Command rg) → set ripgrepPath.
  • On Windows only rg.exe is used (not .cmd / .bat).

Workspace search is missing a file I expect to see Check prismSearch.workspaceSearch.excludeGlobs and respectFilesExclude — a pattern may be excluding it. Files over maxFileSizeMB (2MB by default), or scans beyond the file-count / result limit (maxFiles / maxResults), are also skipped (see "Known Limitations").

The input turns orange, or shows no matches, in regex mode The pattern was flagged as a possible catastrophic-backtracking risk and wasn't executed, for safety (see "Regex Mode Security Note"). Simplify the pattern, or use literal search instead.

The Undo button is greyed out It's only enabled right after a Replace/Replace All, and only until you edit that file again (anything at all, even unrelated to this search box). This is intentional — it avoids the risk of undoing the wrong edit. Use Ctrl+Z if you've already made another change and still want to undo the replace. (This applies to current-file boxes; for workspace-wide Replace All, Undo stays available until you use it.)


License

This project is licensed under the MIT License. (See LICENSE file) Free to use, modify, and redistribute.

The icon font (Codicons) bundled with this extension is © Microsoft Corporation, licensed under CC BY 4.0. (See THIRD_PARTY_NOTICES.md)


Author

uta


Repository

https://github.com/uta1214/prism-search


日本語版 (Japanese)

複数の検索語をそれぞれ別の検索ボックスで管理し、色分けしてハイライトする拡張機能です。現在のファイルだけでなく、ワークスペース全体も検索できます。


✨ 主な機能

  • 複数の独立した検索ボックス — 検索語・色・オプション(大文字小文字/単語単位/正規表現)をそれぞれ個別に管理
  • 複数色での同時ハイライト — アクティブなエディタと、表示中の分割ペイン全てに同時表示
  • マッチ間の移動 — ▲▼や Enter / Shift+Enter で各ボックスのマッチを順に移動
  • ワークスペース全体の検索・置換 — ripgrepを使えば高速化・.gitignore自動対応も可能
  • ボックスごとの置換 — ワークスペース全体のReplace Allは確認ダイアログ+ワンクリックUndo付き
  • 選択範囲内検索(Find in Selection) — 現在の選択範囲だけに絞って検索。ワークスペース検索中でも併用可能(後述)
  • 結果の保存 — ワークスペース検索のボックスの結果を、マッチした行ごとに「パス:行: 本文」の1行でテキストファイルに保存
  • 検索履歴・クイック操作 — 直近の検索語を再利用、キーバインド/アイコンでカーソル位置の単語を即検索

🔍 使い方

ハイライト

  • 検索ボックスに入力すると、アクティブなエディタ内がその色でハイライトされる。分割ペインも全てハイライトされる(非アクティブなペインは少し暗く表示)
  • 「+ Add Search Box」で色パレットの次の色を割り当てた空のボックスを追加
  • Aa / ab / .* で大文字小文字区別・単語単位・正規表現を切り替え
  • 目のアイコンはハイライト表示だけをON/OFF(検索自体は止まらない)。✕ でボックスを削除

移動

  • ▲▼、または入力欄で Enter / Shift+Enter で次/前のマッチへ移動。カーソル位置から開始し、末尾/先頭で循環
  • マッチ数(1/12)は常に「次へ」で実際に着地する位置と一致する

ワークスペース検索

  • フォルダアイコン📁でワークスペース全体検索に切り替え。結果はボックス下にファイル/行のクリック可能な一覧で表示
  • 「Include」欄で検索対象ファイルを名前/パスで絞り込み(プレーンテキストまたはglob、カンマ区切り):
    • {} や [] の中のカンマは区切りとして扱わないので、*.{ts,tsx} は1つのパターンとして使える
    • *.ts のように / を含まないglobは、VS Code標準の検索と同じくどの階層にも一致する
    • ./ で始まる項目と、ワークスペース内の絶対パスは、ワークスペースのルートから固定したパスとして扱う。./src は「ルート直下の src フォルダとその中身すべて」を指し、「src」を含むだけのパスには一致しない。. は全ファイル。./*.ts のように / を含まない項目では ./ は効果がなく、どの階層にも一致する
    • 複数フォルダのワークスペースでは、そのように固定した項目は各フォルダに適用されるので、複数のフォルダに存在する同じパスはすべて一致する
    • Windowsでは、src\utils のように「\」区切りで書いた素のテキストは src/utils として扱われる
    • ripgrepを使う場合、.gitignore で除外されるファイルは、Includeを指定しても除外されたまま
  • 結果は現在のファイルに近い順に並ぶ
  • Include欄の右にある🔄ボタンで、同じ条件のままワークスペース検索をやり直せる。ファイルが変わっても自動では再検索しないので、ファイルを編集した後などに使う
  • ワークスペース検索の実行中も、直前の結果一覧は(薄く表示されたまま)残り、件数バッジは空になる代わりに現在のファイル内の位置/件数に末尾の … を付けて表示される(例: 2/7…)。この間も Enter や ▲▼ は現在のファイル内のマッチを移動でき、検索が完了するとワークスペース全体の移動に切り替わる。内蔵スキャナでは、見つかったマッチから順に一覧へ追加され、走査済み/全体のファイル数 も表示される。非常に大きなプロジェクトではripgrep(prismSearch.workspaceSearch.useRipgrep)を有効にすると大幅に速くなる
  • Find in Selectionとの併用: ワークスペース検索中でも選択範囲アイコンをONにすると、現在アクティブなファイルのハイライト・件数バッジ・上下ナビゲーション・Replace Allが選択範囲内だけに絞り込まれる。ボックス下の一覧(ファイル/行リスト)はこれに関わらず全ファイルの全マッチを表示したままになる ―― 絞り込まれるのはバッジ・上下ボタン・実際に書き換わる範囲だけ

置換

  • 置換アイコンでReplace / Replace All / Undoを表示
  • 現在のファイル: Undoは直前に行った置換(ReplaceまたはReplace All)を1件戻す。ただし、その置換の後にそのファイルへ何か編集をしていないときだけ有効 ―― Undoボタンは置換直後だけ押せる状態になり、(このボックスと無関係なものも含めて)何か1つでも編集をすると自動的に無効(グレーアウト)になる。誤って別の編集を戻してしまわないための仕様。それ以降に取り消したい場合は Ctrl+Z を使う
  • ワークスペース全体: Replace Allのみ利用可(実行前に対象件数の確認ダイアログあり)。各ファイルへの変更は独立しているため、Ctrl+Zは今のファイルにしか効かない。まとめて戻すにはUndoボタンを使う。一回限りだが、使うまでは他の編集をしても有効のままで、戻す前に各箇所の内容を確認し、置換後に内容が変わっていた箇所はスキップして知らせる
  • 正規表現モードでは置換後文字列に $1, $2, $0($& と同じ), $$ に加えて、\n(改行)・\t(タブ)・\\(バックスラッシュ1つ)が使える(VS Code標準の置換と同じ)。それ以外の \x は入力したまま残る
  • 正規表現は、可能な場合はUnicodeフラグ付きで実行するので、\p{L} や \u{1F600} が使え、. や [^a] は絵文字を1文字として扱う。Unicodeモードで不正になる、記号の無意味なエスケープ(文字クラスの外の \-、\_、\@、\# など)はそのまま受け付けるので、\p{L} や絵文字と組み合わせても動く。それでもUnicodeモードで不正な書き方は、自動的に従来のモードにフォールバックするので、これまでのパターンはそのまま動く
  • 正規表現はVS Code標準の検索と同じく行ごとに照合するので、行末の空白を消す \s+$ や [^,]+ が、改行を飲み込んで空行を消したり行をまたいだりすることはない。行をまたいで照合するのは、\n・\r・\W を含む正規表現(または検索語に実際の改行を含む場合)だけ。そのため [\s\S]*? のような「何でも」にマッチさせる書き方だけでは行をまたがなくなったので、start\n(.*\n)*?end のように改行を明示して書く(VS Code標準の検索と同じ挙動)。CRLFのファイルでも、そのような正規表現の \n(と \W)は、改行(\r\n)1つ分に一致する(VS Code標準の検索と同じ)ので、foo\nbar は foo・CRLF・bar に一致する。\r を含む正規表現(\r\n・\r?\n など)は、ファイルの生のテキストに対して照合する。ワークスペース検索では、ファイル末尾の改行より後ろの空行は1行として数えない(ripgrepと同じ)ので、$ を ; に置換しても各ファイルの末尾に余分な行は増えない
  • 空マッチはVS Code標準の検索と同じように扱う: ^・$・\b・先読み/後読みは、文字を消費しない「位置」にマッチするので、Replace / Replace All でテキストを挿入できる(例: ^ を // に置換して全行をコメントアウト、$ を ; に置換して全行の末尾に追加)。空マッチは、その位置の右隣の1文字(^ なら行の1文字目)を、右隣が無ければ左隣の1文字($ なら行の最後の文字)を塗って示す。完全な空行(塗れる文字が無い行)では、行頭に1文字分の幅の印を描く。直前のマッチの終端と同じ位置の空マッチ(例: aab を a* で検索したときの aa の直後の空マッチ)は、ripgrepと同じく数えない。空マッチも1件として数えるので、1ボックスあたり5000件の上限にも含まれる

結果の保存

  • ワークスペース検索のボックスでは、(絞り込み欄にある)再検索ボタンの右隣の保存アイコンで、結果をテキストファイルに保存できる。先頭に見出し(日時・ワークスペース・検索語・オプション・Include)を書き、続けてマッチした行を1行ずつ「パス:行: 行の全文」で並べる。同じ行に複数のマッチがあっても1行にまとめ、見出しにマッチ数・行数・ファイル数を書く
  • アイコンが押せるのは、そのボックスの検索結果が表示されている間だけ。検索の実行中(再検索ボタンを押した直後や、検索語を変えた直後を含む)や、結果が0件のときは押せない。現在のファイルのボックスには表示されない
  • 結果は表示されている順のまま保存する。保存ダイアログの既定のファイル名は prism-search_ワークスペース名_検索ワード.txt(ファイル名に使えない文字は _ になり、長い名前は短くされる)。保存先は前回使ったフォルダから始まる。保存後の通知のボタンから、保存したファイルを開ける
  • 行はファイルから読み直すので、省略されたプレビューではなく行の全文が保存される(極端に長い行は、マッチの周辺約2,000文字に切り詰める)。検索後にファイルが編集されて、その行が見つかったときの内容と変わっている場合は、その行だけ結果一覧の省略プレビューを使い、見出しにその旨が書かれる
  • 結果が不完全なとき(結果数やファイル数の上限に達した、遅い正規表現でファイルをスキップした、サイズ上限を超えるファイルは検索対象外、など)は、見出しにその旨が書かれる

その他のショートカット

  • Ctrl+Alt+F で選択範囲(無ければカーソル位置の単語)を新規検索語として、新しいボックスに追加(末尾のボックスが空でも再利用しない)。その入力欄の末尾へフォーカスを移す(全選択はしない)。そのまま Enter で次のマッチへ移動できる。キャレットがすでにマッチの上にある場合(取り込んだ単語など)、最初の Enter はその次のマッチへ直接移動する。選択も単語も無い場合は、新しい空のボックスを追加してフォーカスするので、そのまま入力を始められる
  • Prism Search: Add Search Box(Ctrl+Alt+F、コマンドパレット、エディタの右クリックメニュー。メニューにはショートカットが併記される)は、選択範囲(無ければカーソル位置の単語)があればそれを入れ、無ければ空のボックスを追加する(どちらも常に新規作成で、既存の空ボックスは再利用しない)。パネル下部の「Add Search Box」ボタンとタイトルバーの +(Prism Search: Add Empty Search Box)は、エディタの単語を見ずに、常に新しい空のボックスを追加して入力欄へフォーカスする
  • Prism Search: Add Search Box Without Opening Sidebar(Ctrl+Alt+Shift+F、コマンドパレット、エディタの右クリックメニュー)は、上のコマンドと同じく選択範囲(無ければカーソル位置の単語)を新しいボックスに追加するが、サイドバーは開かず、フォーカスもエディタのまま動かさない。エディタで作業を続けたまま、気になった語を次々にハイライトへ加えるときに便利。追加した語はすぐにハイライトされ、ステータスバーに短く知らせる。ボックスは、次にサイドバーを開いたときに(VS Codeを再起動した後も)そこにある。選択も単語も無い場合は、空のボックスは見えないので、何も追加しない
  • ボックスの入力欄(検索語・置換語・Include)にフォーカスがあるとき、Ctrl+Alt+C で大文字小文字の区別、Ctrl+Alt+W で単語単位、Ctrl+Alt+R で正規表現を切り替え(macOSでは Cmd+Option+C/W/R)。ワークスペース検索で Enter / ▲▼ / 結果のクリックをしても、フォーカスはサイドバーに残る(VS Code標準の検索ビューと同じ)。Esc でエディタへフォーカスを戻す
  • 各ボックスのターゲットアイコンも同様だが、常にそのボックス自身に入力する
  • 履歴アイコンでこのワークスペースの直近の検索語を表示
  • 色ドットでカラーピッカーを開く。変更後はリセットボタンが表示される
  • 選択範囲アイコンで Find in Selection(選択範囲内のみ検索)をON(ワークスペース検索との併用も可能、上記参照)。表示される🔄アイコンは、その時点の選択で範囲を捕捉し直す。範囲自体はワークスペースに保存され再起動後も復元されるほか、その後のファイルへの編集にも正しく追従する。行をまとめて選んだ場合(Shift+↓などで、選択が次の行の先頭で終わるとき)は、選んだ最後の行の末尾までを範囲とするので、その次の行は対象にならない(VS Code標準の「選択範囲内を検索」と同じ)。範囲の端ちょうどに挿入されたテキスト(Replace Allによる挿入など)は範囲に含まれるので、同じ選択範囲で続けて操作できる(例: ^ → // で行頭にコメントを付け、続けて ^// → 空 でコメントを外す)
  • タイトルバー下の専用ツールバーで、表示/ワークスペース検索/大文字小文字区別/単語単位/正規表現を全ボックス一括切り替え
  • 検索ボックスの状態はワークスペースごとに保存され、再起動後も復元される

⚡ Ripgrep統合

ワークスペース検索は既定で内蔵スキャナを使用。prismSearch.workspaceSearch.useRipgrep をONにすると、PATH上に rg(ripgrep)があればそちらを使用する(高速・.gitignoreを自動で尊重):

{
  "prismSearch.workspaceSearch.useRipgrep": true,
  // 任意: rgのフルパス(空ならPATHから探す。"~" も使える)
  "prismSearch.workspaceSearch.ripgrepPath": "~/.local/bin/rg",
  // ワークスペース検索の結果の最大件数(既定 20000、0 で無制限)
  "prismSearch.workspaceSearch.maxResults": 20000,
  // 内蔵スキャナのみ: 1回の検索で読むファイル数の上限(アクティブなファイルに近い順。既定 2000、0 で無制限)
  "prismSearch.workspaceSearch.maxFiles": 2000,
  // これより大きいファイルは、どちらのエンジンでも対象外(既定 2、範囲 0.1〜100)
  "prismSearch.workspaceSearch.maxFileSizeMB": 2,
  // 正規表現1回の実行に許す最大時間(ミリ秒。既定 1000、範囲 100〜10000)
  "prismSearch.regexTimeoutMs": 1000
}

ripgrepは同梱していません。rg が見つからない場合、または一部のパターンが非対応な場合(例: 先読み/後読み)は、その検索だけ内蔵スキャナへフォールバックします。ONにしても壊れることはありません。検索ごとの事情(例: 先読みを含む正規表現)で切り替わったときは、理由を通知でお知らせします(同じ理由の通知は1ウィンドウにつき1回だけです)。なお、検索語に改行を含む場合(複数行の選択範囲など)は、ripgrepが行単位で検索するため、常に内蔵スキャナで検索します。

rg は、prismSearch.workspaceSearch.ripgrepPath(設定されていれば)、次にPATHの順に探します。ripgrepPath(または useRipgrep)を変更すると、ウィンドウの再読み込み無しですぐ反映されます。ripgrepを後からインストールした(またはPATHを直した)場合は、拡張機能ホストがVS Code起動時の環境変数しか見られないため、VS Codeを(すべてのウィンドウごと)完全に終了して起動し直してください。安全のため、開いているワークスペースフォルダの内側にあるPATHのエントリは無視されます(例: ホームフォルダを開いている場合、~/.local/bin は対象外)。その場合は ripgrepPath を設定してください。ripgrepPath は、ユーザー・リモート・ワークスペースのどの設定でも指定できます(優先順位: ワークスペース > リモート > ユーザー)。ユーザー設定で一度指定してどこでも使うことも、リモートの設定だけで上書きすることもできます。リモートウィンドウ(WSL・SSH・Dev Container)ではリモート側に存在するパスが必要です。ユーザー設定のローカルのパスが存在しない場合は「使える rg ではない」という警告が出てPATHから探すので、その場合はリモートの設定で ripgrepPath を指定してください。信頼されていないワークスペースでは、ワークスペース側の値は無視されます。


📁 ワークスペース全体検索の除外設定

// .vscode/settings.json (ワークスペース単位) または ユーザー設定
{
  "prismSearch.workspaceSearch.excludeGlobs": [
    "**/node_modules/**",
    "**/.git/**",
    "**/dist/**",
    "**/generated/**"
  ],
  "prismSearch.workspaceSearch.respectFilesExclude": true
}
  • excludeGlobs は既定の除外リストを丸ごと上書きする(必要なら自分でコピー&追記)
  • .git(フォルダ・ファイル)は excludeGlobs の設定にかかわらず、ワークスペース検索とReplace Allの対象から常に除外される
  • respectFilesExclude(既定ON)は、VS Codeのfiles.exclude / search.excludeのパターンもあわせて除外する
    • 値が true のものだけが使われる。{ "**/*.js": { "when": "$(basename).ts" } } のような条件つきの指定は、条件を評価できないため適用されない(適用すると、すべての .js が検索・Replace Allの対象から外れてしまうため)

⚙️ その他の設定

{
  // 非アクティブな分割ペインにもハイライトを表示するか(既定: true)
  "prismSearch.highlightInactiveEditors": false,

  // 新規作成する検索ボックスの既定値
  "prismSearch.newSearch.caseSensitive": false,
  "prismSearch.newSearch.wholeWord": false,
  "prismSearch.newSearch.regex": false,
  "prismSearch.newSearch.scope": "file" // または "workspace"
}

⚠️ 既知の制約

  • ripgrepを使わない場合、.gitignore は考慮されない(VS Code API側の制限)。excludeGlobs でカスタマイズ可能
  • ワークスペース検索は、内蔵スキャナ・ripgrepのどちらでも隠しファイル/フォルダ(.github、.env など)を対象に含み、Replace Allでも変更されうる。検索・置換したくないものは excludeGlobs に追加する(.git は常に除外され、既定では node_modules なども除外される)
  • ワークスペース検索は、正しいUTF-8とUTF-16(BOMあり)のファイルを直接読む。それ以外の文字コード(Shift_JIS、EUC-JPなど)のファイルは、VS Code自身のデコード結果を使って読むため、VS Codeが正しく開ける場合(files.encoding の設定、または files.autoGuessEncoding を有効にする)のみ検索できる。ripgrepを有効にしている場合、ripgrepがUTF-8として不正な行にマッチしたファイルは、VS Codeのデコード結果で読み直すので、そのような行のマッチは取りこぼさない(たとえば TODO は、日本語を含む行でも見つかる)。ただしripgrep自体はUTF-8のテキストにしか一致しないため、そのようなファイルの中の非ASCII文字を検索語にしても、このエンジンでは見つからない(その場合はripgrepをOFFにする)
  • 検索語と検索履歴は、VS Codeのワークスペース用ストレージ(ローカルPC内)に平文で保存される。APIキーやパスワードなどを検索ボックスへ入力したくない場合はご注意ください
  • 正規表現の実行が長すぎる場合(1ファイルで prismSearch.regexTimeoutMs 超。既定1秒)、そのファイルはスキップされる。スキップされたファイル数は結果一覧に表示され、現在のファイルが該当する場合は検索ボックスにも警告が出る
  • ripgrepの正規表現エンジンは先読み/後読み/後方参照に非対応。該当パターンはワークスペース検索時に自動で内蔵スキャナへフォールバック
  • JavaScript(エディタのハイライト・内蔵スキャナ)とRust(ripgrep)では、((?:-?)*?)* のような入れ子の繰り返しの中の「空の繰り返し」の扱いが異なる。このような特殊なパターンでは、エディタとripgrepによるワークスペース検索結果とで、マッチの長さが食い違うことがある
  • JavaScriptとripgrepでは、文字の細かい扱いも一部異なる: \s(JavaScriptはU+FEFFを含み、ripgrepはU+0085を含む)と .(ripgrepはU+2028 / U+2029にもマッチし、JavaScriptはマッチしない)。実際に影響することはまれだが、ripgrepの有無で同じ検索の結果がわずかに変わることがある
  • ワークスペース検索は、LF(とCRLF)だけを行の区切りとして扱う。単独のCRを改行にしているファイル(ごく古いMac形式)は、エディタではCRごとに行が分かれるため、結果の行番号がエディタとずれることがあり、Replace Allでは内容が一致しなくなった箇所を飛ばす(スキップした件数が表示される)
  • ワークスペース検索は、合計で prismSearch.workspaceSearch.maxResults 件まで結果を保持する(既定 20000。VS Code標準の search.maxResults と同じ。0 で無制限だが、範囲の広い検索では遅くなったりメモリを多く使うことがある)。1ファイルあたりの上限は無い。上限に達すると、バッジに + が付き(例: 20000+)、一覧にも「結果の一部のみ」と表示される。設定は次の検索から反映される(すぐ反映するには 🔄 再検索ボタン)。どちらのエンジンも、prismSearch.workspaceSearch.maxFileSizeMB(既定2MB、最大100MB)を超えるファイルをスキップする。内蔵スキャナはこれに加えて、prismSearch.workspaceSearch.maxFiles(既定 2000)のファイルまでを対象にする(現在のファイルに近い順。0 で無制限だが、非常に大きなワークスペースでは遅くなることがある。ripgrepにファイル数の上限は無い)。これらの設定は次の検索から反映される。結果一覧は仮想スクロールで、見えている範囲の行だけを描画するため、数万件でも軽く動く。Include(filename / glob)欄はスキャン時に適用されるので、描画されている行だけでなく、結果の全体に対して絞り込まれる。現在のファイル内のマッチは1ボックスあたり5000件まで(バッジは 5000+)、Replace Allは1回の実行で最大5000件まで置換し、残りがあれば完了メッセージで知らせる(もう一度実行すれば続きを置換できる)
  • ripgrepでIncludeを使うと、.gitignore で除外されるファイルのマッチは、ripgrepが結果を返した後に取り除かれる。結果の上限に達してripgrepが途中で止まった場合は、それらのファイルが先に上限の一部を使っていることがあり、一覧が上限から想像するより短くなりうる。Includeを絞り込むと避けられる
  • ワークスペース検索は検索語/オプション変更時のみ再実行(他ファイルの背後での変更は自動検知しない)
  • Find in Selectionの範囲は捕捉した時点のまま固定され、その後のカーソル/選択の変化には自動追従しない(選び直したい場合は🔄アイコンを使う)。ただし、そのファイル自体への編集(改行・置換など)には正しく追従する
  • ワークスペース検索と併用した場合、Find in Selectionが絞り込むのはアクティブなファイルのバッジ・ナビゲーション・Replace Allのみで、ボックス下の一覧(ファイル/行リスト)は常にワークスペース全体の全マッチを表示したままになる

🛡️ 正規表現モードのセキュリティ上の注意

正規表現は実際のJavaScript RegExp として実行されます。(a+)+ のような入れ子の量指定子は「壊滅的バックトラッキング」を起こすことがあります。この拡張機能は代表的なパターンを事前にブロックし(入力欄がオレンジ枠になる。(\w+\.)+\w+ や ([^,]+,)+ のように、必須の区切り文字で繰り返しの境目が一意に決まるパターンはブロックしない)、さらに安全網として、すべての正規表現の実行に制限時間(既定1秒。prismSearch.regexTimeoutMs で100〜10000ミリ秒の範囲で変更できます。パターンの実行中は拡張機能ホストが止まるため、大きくしすぎないでください)を設けています。(a|aa)+$ のようなパターンが長く実行され続けた場合は中断され、危険なパターンとして記録されて(オレンジ枠)以降は実行されないため、拡張機能ホストが固まり続けることはありません。ただし中断されるまでに最大でこの制限時間ぶん待たされることはあります。心配な場合はリテラル検索を使ってください。ripgrepによる検索自体は、エンジンの特性上この問題が起こらないため、これらのチェックの対象外です。

ワークスペースの信頼(Workspace Trust): 信頼されていないワークスペースでは、prismSearch.workspaceSearch.useRipgrep・ripgrepPath・excludeGlobs・respectFilesExclude・maxResults・maxFiles・maxFileSizeMB・regexTimeoutMs のワークスペース側の値は無視されます(ユーザー設定は有効)。リポジトリ側から、ファイルの走査方法を変えられないようにするためです。


🛠️ トラブルシューティング

ripgrepをONにしたのに使われている気配がない rg がインストール済みか確認してください(ターミナルで rg --version を実行)。見つからない場合、または prismSearch.workspaceSearch.ripgrepPath のパスが使えない場合は、一度だけ警告通知が表示され、内蔵スキャナにフォールバックします(内蔵スキャナの検索中は状態表示が 走査済み/対象 files(対象は走査するファイル数で、最大でも maxFiles。既定は2000)のようになり、ripgrepでは「Searching…」だけが表示されます)。主な原因と対処:

  • rg が、開いているワークスペース内のフォルダにある(例: ホームフォルダを開いていて、rg が ~/.local/bin にある)→ prismSearch.workspaceSearch.ripgrepPath にフルパスを設定する
  • rg のインストールやPATHの追加より前にVS Codeを起動した(拡張機能ホストは起動時の環境変数しか見られない)→ VS Codeを完全に終了して起動し直す、または ripgrepPath を設定する
  • rg がシェルのエイリアスや関数で、PATH上の実行ファイルではない(which rg / Get-Command rg で確認)→ ripgrepPath を設定する
  • Windowsでは rg.exe のみが対象(.cmd / .bat は不可)

ワークスペース検索で期待したファイルが出てこない prismSearch.workspaceSearch.excludeGlobs と respectFilesExclude を確認してください。パターンに引っかかって除外されている可能性があります。maxFileSizeMB(既定2MB)を超えるファイルや、ファイル数/結果件数の上限(maxFiles / maxResults、「既知の制約」参照)を超えた分もスキップされます。

正規表現モードで入力欄がオレンジ枠になる/マッチが出ない 壊滅的バックトラッキングの疑いがあるパターンとして検出され、安全のため実行されなかった状態です(「正規表現モードのセキュリティ上の注意」参照)。パターンを単純化するか、リテラル検索を使ってください。

Undoボタンがグレーアウトしていて押せない Undoが有効なのは置換(Replace/Replace All)の直後だけで、その後そのファイルに何か編集(このボックスと無関係なものも含む)をすると自動的に無効になります。誤って別の編集を巻き戻してしまわないための仕様です。それ以降に取り消したい場合は Ctrl+Z を使ってください。(これは現在のファイルスコープのボックスの話で、ワークスペース全体のReplace Allを戻すUndoは、使うまで有効のままです。)


ライセンス

このプロジェクトのライセンスは MIT です。(LICENSE ファイル参照) 自由に利用・改変・再配布が可能です。

この拡張機能に同梱しているアイコンフォント(Codicons)は Microsoft Corporation の著作物で、CC BY 4.0 のもとで提供されています。(THIRD_PARTY_NOTICES.md 参照)


作者

uta


リポジトリ

https://github.com/uta1214/prism-search


  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft