Fork from https://github.com/earshinov/vscode-filter-lines
This extension allows you
- To filter text of the current document by a regular expression and output matched or matched group(s).
- To replace text of the current document by a list of find and replace and output replaced text.
// Example text
// Output of Replace List: 1:11,2:22
// Output of Include Matched: \d(\w)
// Output of Include Matched Group: \d(\w)
All of the following commands are available via Ctrl-Shift-P.
|Find Replace: Replace List
||Ctrl-K Ctrl-R *
|Find Replace: Include Matched
||Ctrl-K Ctrl-M *
|Find Replace: Include Matched Group
||Ctrl-K Ctrl-G *
* Use cmd instead of ctrl on Mac
s (DOTALL) flag if you want to match multiple lines.
See MDN for syntax reference, but
keep in mind that you need to prefix flag between
(?gs) and inner part of the regex without the enclosing slashes (
You can prefix flags between
(?gis). If not prefixed default
gs flags will be used.
Following is RegExp flags
g(global): Don't return after first match
m(multi line): ^ and $ match start/end of line
i(insensitive): Case insensitive match
y(sticky): Anchor to start of pattern, or at the end of the most recent match
u(unicode): Match with full unicode
s(single line): Dot matches newline
d(indices): The regex engine returns match indices
Following is extension specific flags
p(path): Read find and replace value from file path. Use
+ to specify multiple path like
c(change): Change key and value. For example,
a:1 means replace
a, but means replace
c flag used.
w(word): Find word only by enclosing find value with
[\s,.:;"'] to prevent replace again case. Target will change to value when
c flag used.
|Tells the extension to preserve the search string.
|Tells the extension to preserve the default flags.
If you are using Settings UI, you will find these settings under "Find Replace" section.
Under the hood: Available commands ids
You can use these command ids to make your own keybindings.
Implements the "Find Replace: Replace List" command with output of replaced.
Input value is combined with comma(,) and colon(:) when read from user input, but line delimeter when read from file.
1:11,2:22 must be replaced to
1:11\r\n2:22 when you enter file path in input box.
- Use doubled value like
File path rule
- Can use relative path (ex:
data/a.txt to get
data folder inside current workspace folder)
- Can be combined with
data/a.txt+data/b.txt to get
Implements the "Find Replace: Include Line" command with output of only matched.
Implements the "Find Replace: Include Line" command with output of only matched group(s).
You can find this extension in the Visual Studio Marketplace.