Have you suffered issues below in your daily work?
- Find Definition: Unable to
jump-to-definition
?- Lack of dependency packages / build , or failed to build?
- IDE/extension often caught some problems?
- Cannot cross
multiple languages
?C#
,C++
,Java
/Scala
,Python
,Proto
, etc. - Cannot cross
multiple repositories
?
- Search Code
- Clumsy and slow in IDE? Too narrow
vscode
panel to preview? - Wasting time to click and expand each item?
- Lack of a powerful tool to learn/ramp-up code by yourself ? (filter + stats + compare/analogy).
What if
a colorful + fast glance for all search results + rich and powerful filters?
- Clumsy and slow in IDE? Too narrow
- Replace File Text
- Missed changes to some files(like
doc
/config
) or other languages not loaded in IDE? - Your replacing tool added or removed the
tail empty line
? And cause wronggit diff
? - Your replacing tool changed your file time even nothing changed?
What if
a fast way to replace? Just reuse thepowerful search used above
?
- Missed changes to some files(like
- Just read code but inefficient ? or insufficient resource on laptop?
- Too slow + hard to prepare environment for IDE to load code? Especially from other teams?
- Must install X GB language plugins?
- Must download Y GB packages to the disk?
- Must build Z GB outputs to the disk (like C#) before you can read code?
- Offer N GB running memory to the
official/professional
language extensions?
Then it's the light + right tool for you(2~3 MB storage + 1~5 MB running memory) to search + replace file text.
Note: (Temp-toggle or change settings for languages disabled by default settings.)
You can start search + replace + code mining via mouse/menus + keys + terminals without reading/doing anything except:
- Cook doskey/alias if you want to search/replace out of vscode (in
CMD
/Bash
+ other IDEs).- See Best Practice to search/update repo + Get Combined Power.
- Create custom common alias(see difference) once-for-all to auto sync across all vscode + platforms.
- For Windows: Trust msr if you cannot get search results in 1~2 seconds for code files <= 10000.
- For WSL: Use short mount paths for WSL to enable clicking result file paths + locate into IDEs.
- Adjust output colors of both file paths and matched text with 2 methods.
- Windows
x86_64
+x86_32
: Version >=Windows XP
including MinGW on 64-bit + 32-bit Windows.Arm64
: Version >=Windows 8.1
.- Cygwin: Version >=
Cygwin 5.4.0
. - WSL: Same with
Linux
below.
- Linux
x86_64
+x86_32
: Kernel >=2.6.32
: 64-bit + 32-bit Ubuntu + CentOS + Fedora.Arm64
: Kernel >=4.15
(likeUbuntu 18.04
).
- MacOS
Arm64
: Version >=Darwin 21.1.0
.
- FreeBSD
amd64
: Version >=FreeBSD 11.0
(older versions may work but not tested).
-
Search 20000+ code files in 1~3 seconds after first time (10~30+ seconds, SSD maybe faster).
-
Fast find definitions + references for all types of coding languages across multiple related repositories.
-
Self-reliance: Learn/Ramp-up faster by yourself -- Code Mining without or with Little Knowledge.
-
Normal + Extensive Search: Search by hot-keys/menus or typing text, in or out of VSCODE.
-
Easy + Fast to Search Further or Replace File Text: Just reuse the search command line by an upper arrow.
-
Powerful + Convenient command alias to search/replace code/config/doc files in/out-of
vscode
. -
Easy + Fast to Get the Best Combined Power of
vscode-msr
+ official language plugins. -
Every function is under your control and easy to enable or disable.
-
Easy to Support New Languages with 2 methods.
-
Automated command shortcuts on Linux + WSL + 4 types of terminals on Windows.
-
Simple + flexible config: General Regex of
C++
,Java
,C#
,Python
. -
All just leverage tiny msr+nin EXE without
storage
/cache
,server
/service
,network
, etc.
Screenshot-1: Search Definitions + References for C++ / Python / Java in vscode
:
The cooked/dumped alias/doskey Can be used in Many IDEs, Not just VSCode
Cook + Dump script files for other IDEs or system terminals out of vscode.
Since out of vscode
, no menus/mouse support, use gfind-xxx
/find-xxx
to search and replace, see screenshot-2:
More powerful usages + examples see overview doc or just run msr/nin to see color doc (Windows, Linux here) or text doc.
Auto added msr folder to %PATH%
(Windows) or $PATH
(Linux) to help your daily file processing.
If not found msr in %PATH%
or $PATH
:
- Windows: If not found in
%PATH%
by command"where msr.exe"
- Auto check and download to
%USERPROFILE%\msr.exe
when launching vscode. - Add
%USERPROFILE%
to%PATH%
temporarily each time in each newly opened terminal.
- Auto check and download to
- Linux/MacOS/FreeBSD: If not found in
$PATH
by command"which msr"
- Auto check and download to
~/msr
when launching vscode. - Add
~/
to$PATH
temporarily each time in each newly opened terminal.
- Auto check and download to
This helps using msr
command lines or find-xxx
/gfind-xxx
outside vscode
.
See manually downloading tool command lines on Windows
/Linux
/MacOS
/FreeBSD
.
- You can also get downloading command line from
MSR-Def-Ref
channel inOUTPUT
tab. - Delete existing
msr
/nin
if now show command or if you want to update immediately.- Check location like
where msr
(Windows) orwhich msr
(Linux/MacOS/FreeBSD).
- Check location like
If the color
of output result file paths is not clear to read when using default dark-blue
color theme.
To adjust the colors, for example, if it's default dark-blue
color theme:
- Open your vscode user settings file with
code
or other tools like:- Windows:
- code
%APPDATA%\Code\User\settings.json
- code
- Linux:
- code
$HOME/.config/Code/User/settings.json
- code
- Windows:
- Add or change terminal.ansiBrightBlue like below: (Add outer brackets
"{ }"
if the file is empty)
"workbench.colorCustomizations": {
"terminal.ansiBrightBlue": "#5833ff"
}
More details or other color settings follow official vscode doc.
You can set environment variable MSR_COLORS to change color-groups of both file paths and matched text:
-
Temporarily set env in a terminal/console:
- Windows example for color group of
result file paths
:set MSR_COLORS=p=Green
orset MSR_COLORS=d=Cyan,f=Green
- Linux/MacOS/FreeBSD example:
export MSR_COLORS=p=Green
orexport MSR_COLORS=p=Cyan,f=Green
- Windows example for color group of
-
Temporarily set env in user settings like command above:
- Windows:
- Add/update
msr.cmd.postInitTerminalCommandLine
like"set MSR_COLORS=xxx"
- Add/update
- Linux/MacOS/FreeBSD:
- Add/update
msr.bash.postInitTerminalCommandLine
like"export MSR_COLORS=xxx"
- Add/update
- Cygwin:
- Add/update
msr.cygwinBash.postInitTerminalCommandLine
-"export MSR_COLORS=xxx"
- Add/update
- MinGW:
- Add/update
msr.mingwBash.postInitTerminalCommandLine
-"export MSR_COLORS=xxx"
- Add/update
- Windows:
If you cannot get search results in 1~2 seconds for just 10000 code files:
- Method-1: Follow official Windows doc to add exclusion.
- Method-2: Same with using auto-cooked alias
trust-exe
(run asAdministrator
in anew
CMD window):- Run command "trust-exe
msr,nin
" (input exename
ortitle
orpath
).- Auto get paths + use
PowerShell "Add-MpPreference -ExclusionPath $exePath"
.
- Auto get paths + use
- You can also use
trust-exe
to fixgit
,ssh
,bash
,node
,pip
,python
,golang
etc.
- Run command "trust-exe
You can change the value for small projects which you can prefer precision over speed since it's fast:
- Global change:
msr.default.preferSearchingSpeedOverPrecision
=false
. - For a project:
msr.{project-folder-Name}.preferSearchingSpeedOverPrecision
=false
. - For C# code:
msr.cs.preferSearchingSpeedOverPrecision
=false
.
More override settings see: full priority rule.
Two methods to cook alias files in a second:
- Open any file in vscode, right click, choose menu: "Cook general + Dump other alias to scripts".
- Or use Command Palette like below to find
"msr: Cook xxx"
menus and dump scripts:
This will dump each alias/doskey to a script file:
- Auto transform each alias/doskey to a script file(name = alias) to help searching or replacing text in or out of vscode.
- For Windows:
- Transform each doskeys in
%USERPROFILE%\msr-cmd-alias.doskeys
to a script file.
- Transform each doskeys in
- For MinGW/Cygwin/WSL + Linux/MacOS/FreeBSD:
- Auto load each alias in
~/.bashrc
+~/msr-cmd-alias.bashrc
and transform to a script file.
- Auto load each alias in
- For Windows:
- Save location:
msr.cmdAlias.saveFolder
(default location):- Single alias/doskey file: Save to
%USERPROFILE%\
on Windows or~/
on Linux/MacOS/FreeBSD. - Multiple script files: Save to
%USERPROFILE%\cmdAlias\
on Windows or~/cmdAlias/
on Linux/MacOS/FreeBSD.
- Single alias/doskey file: Save to
Auto set project specific alias for new terminals in vscode, according to repo .gitignore
plus .vscode/settings.json
.
- Windows command to remove registration of doskey file (
msr-cmd-alias.doskeys
):REG DELETE "HKEY_CURRENT_USER\Software\Microsoft\Command Processor" /v Autorun /f
- Linux/MacOS/FreeBSD + MinGW/Cygwin/WSL command:
msr -p ~/.bashrc -t "^source ~/msr-cmd-alias.bashrc" -o "" -R
- Create custom common alias once-for-all to help automate daily work across Windows + Remote SSH hosts + containers.
- Please use
gpc
orgpc-sm
/gpc-sm-reset
/git-sm-xxx
to pull/update your git repository. - Set
msr.refreshTmpGitFileListDuration
to large value(like12hours
/3days
) if you always use them.- Run
gpc
or del-this-tmp-list whenever you need to update git-paths (used by gfind-xxx).
- Run
- 4 methods to solve
gfind-xxx
drawbacks of possible using outdated tmp-git-paths-list:- 1(Radical): Set
msr.refreshTmpGitFileListDuration
with small value like0second
/2m
. - 2(Normal): Run
del-this-tmp-list
beforegfind-xxx
if you added new files, or switched branches, or usedgfind-xxx
in descendant folders. - 3(Inaccurate): Use find-xxx which has same results of
gfind-xxx
most time.- For menus: Change msr.useGitFileListToSearchSingleWorkspace from
auto
tofalse
.
- For menus: Change msr.useGitFileListToSearchSingleWorkspace from
- 4(Inaccurate): Run
update-alias
to switch to general aliasGit_List_Expire
forgfind-xxx
.
- 1(Radical): Set
Use gfind-xxx alias/doskey/scripts which uses accurate source file paths by "git ls-files
".
- This's helpful if got git-exemption-warnings for a git repo.
- You can change
msr.refreshTmpGitFileListDuration
to avoid writing tmp-paths-list too frequently.- See above best practice of integrating update-repo + search/replace code.
- Try rgfind-xxx to search multiple git repositories.
- Use
msr.useGitFileListToSearchSingleWorkspace
for menu search using git file list.- Default =
auto
which use git-file-list only when it's a git repo + found git exemptions.- If no git exemptions,
find-xxx
are same withgfind-xxx
.
- If no git exemptions,
- Set to
true
if you always want to usegfind-xxx
to search. - Set to
false
if you frequently hit drawbacks ofgfind-xxx
+ bored of using del-this-tmp-list.
- Default =
- To skip huge dependent git submodules(sub-repos) for a large project/repository:
- Set
msr.searchGitSubModuleFolders
=false
or set it per repo like:msr.{repo-folder-name}.searchGitSubModuleFolders
=false
.
- Set
Press F1
if not shown in right-pop menu, then search msr Cook xxx
as below:
- General command shortcuts
- Click/Choose
"Cook general alias to 1 file"
to cook general command shortcuts. - Please re-cook this if added new languages support including fastest adding.
- Will not auto update if once cooked + nothing changed (like
msr.xxx.definition
settings).
- Will not auto update if once cooked + nothing changed (like
- Click/Choose
- Project specific shortcuts
- Choose
"Cook project specific alias to 1 file"
for current git repo. - Not recommended unless you only work with 1 project.
- Choose
- Notes for both general + specific shortcuts in single file:
- Auto initialized and effect in vscode when opening new terminals:
- Skip paths Regex:
--np "skip-by-git-ignore"
(if enabled git-ignore). - Skip folders Regex:
--nd "default-and-project-exclude"
- Skip paths Regex:
- System console (
CMD/bash
) will auto load thesedoskey/alias
when opening new terminals.
- Auto initialized and effect in vscode when opening new terminals:
Choose menus below: More freely to use (in other script files or nested command lines like pipe)
"Cook scripts: General alias"
"Cook scripts: Project specific alias"
"Cook general + Dump other alias to scripts"
This enables you to use alias/doskeys (like find-def
) everywhere like:
- Nested commands/pipe like
for-loop
in CMD/Bash +while-loop
, etc. - Script files (like
*.cmd
+*.bat
+*.sh
+*.ps1
etc.) - Interactive
PowerShell
terminal/console (PowerShell
cannot usedoskey/alias
).
- Tip for msr advantage on Windows(including
MinGW
+Cygwin
) + Linux/MacOS/FreeBSD:- Use
"\1"
instead of"$1"
to avoid conflict if yourdoskey
/alias
containsRegex-Replacing
:Regex $1
conflicts withdoskey macro
variables like $1 on Windows.Regex $1
conflicts withbash
variables like $1 on Linux/MacOS/FreeBSD.
- Same that using \2 \3 is better than $2 $3 and etc.
- Use
- For full or relative result file paths:
- Type
out-fp
to output full file paths of search results. - Type
out-rp
to output relative paths.
- Type
Many other common shortcuts like (run alias
to see all alias/doskeys):
- Windows + Linux/MacOS/FreeBSD:
- git shortcuts:
- Type
gpc
to pull current branch +gph
to push current branch +gfc
to fetch current branch. - Type
gpc-sm
/git-sm-reset
to update/reset submodules +git-sm-reinit
as final fix. - Type
git-cherry-pick-branch-new-old-commits
to apply commits between branches.
- Type
- git shortcuts:
- Windows CMD only:
- Now auto output forward slash temporarily in
VsCode
terminals by configmsr.xxx.postInitTerminalCommandLine
.- You can add/remove more MSR_XXX variables like
MSR_EXIT
/MSR_UNIX_SLASH
/MSR_KEEP_COLOR
/ etc.
- You can add/remove more MSR_XXX variables like
- Type
win11-ungroup-taskbar
to ungroup Windows11 taskbar +win11-group-taskbar
to restore/group taskbar on Windows 11. - Type
reload-env
to reload environment variables +reset-env
to clear and reload them. - Type
add-user-path
/add-sys-path
/add-tmp-path
+del-user-path
/del-sys-path
/del-tmp-path
to add/delete %PATH% values.
- Now auto output forward slash temporarily in
- After 1-click cooking-alias, you can add/update alias/doskeys in alias file and search/replace text.
- Automated command shortcuts on MacOS/FreeBSD/Linux + WSL + 4 types of terminals on Windows to search or mining-code or replace file text.
- Use gfind-xxx instead of find-xxx if warned exemptions when initializing new terminals.
- You can search in vscode terminal then click the results to open and locate them.
- You can also start code-mining or replacing files out of vscode (System terminals or other IDEs).
- Run use-this-alias to load alias/env for current git repo.
- If using alias(like
find-spring-ref
) in a nested command (likefor/while-loop
orcommand|pipe
), or script files (like*.bat/cmd
or*.sh
)- Use full-name (like
find-spring-ref.cmd
) or full path (like~/cmdAlias/find-spring-ref
).
- Use full-name (like
Besides normal alias above, you can create custom alias (example + difference) to auto sync across all vscode on all platforms.
Details see Create Custom Common Alias Once and for All in user settings.json for current + future vscode:
msr
.commonAliasNameBodyList for all platforms (Windows + MinGW/Cygwin/WSL + Linux/MacOS/FreeBSD).msr
.cmd.commonAliasNameBodyList
for Windows only.msr
.bash.commonAliasNameBodyList
for MinGW/Cygwin + WSL + Linux/MacOS/FreeBSD.
After cooking alias scripts, you can use rgfind-xxx like rgfind-cpp-ref MySearchWord
to recursively search multiple git repositories in a folder.
- Difference between rgfind-xxx and gfind-xxx:
gfind-xxx
can only be used in a single git repository, not parent folder of multiple git repositories.
- Difference between gfind-xxx and find-xxx (same search results most time):
find-xxx
may waste time on non-repo files thus may not provide accurate results asgfind-xxx
.- But
find-xxx
are better thangfind-xxx
in scenarios below:- New files not in git -
gfind-xxx
cannot find them, usefind-xxx
. - Switched branches or search-folders or sub-modules(without
git-sm-xxx
):- Run del-this-tmp-list before
gfind-xxx
, or usefind-xxx
.
- Run del-this-tmp-list before
- New files not in git -
- But
gfind-xxx
/rgfind-xxx
auto rungit ls-files
first to get precise file list save to a tmp file.
Now you can directly use the command shortcuts in/out-of vscode to search + replace like:
find-ndp path1,path2,pathN -t MySearchRegex -x AndPlainText
find-nd -t MySearchRegex -x AndPlainText
find-code -it MySearchRegex -x AndPlainText
find-small -it MySearchRegex -U 5 -D 5 : Show up/down lines.
find-doc -it MySearchRegex -x AndPlainText -l -PAC : Show pure path list.
find-py-def ClassOrMethod -x AndPlainText : Search definition in python files.
find-py-ref MySearchRegex -x AndPlainText : Search references in python files.
find-cpp-ref "class\s+MyClass" -x AndPlainText --np "unit|test" --xp src/ext,src/common -c show command line.
find-java-def MyClass -x AndPlainText --np "unit|test" --xp src/ext,src/common -c show command line.
find-java-ref MyClass --pp "unit|test" -U 3 -D 3 -H 20 -T 10 : Preview Up/Down lines + Set Head/Tail lines in test.
find-ref OldClassOrMethod -o NewName -j : Just preview changes only.
find-ref OldClassOrMethod -o NewName -R : Replace File Text.
find-spring-ref ABC - find variations of Java Spring member like: ABC / isABC / setABC / getABC.
alias find-pure-ref
malias find- -x ref -H 9
malias "g?find[\w-]*ref"
malias ".*?(find-\S+)=.*" -o "\2" : To see all find-xxx alias/doskeys.
list-alias - list all alias/doskey files of projects.
update-alias - reload common alias/doskeys.
use-this-alias - reload this project alias/doskeys when in vscode; or load by current folder(project) name (see list-alias).
out-rp - Output relative path for result files.
out-fp - Output full path.
Add -W to output full path; -I to suppress warnings; -o to replace text, -j to preview changes, -R to replace file text.
You can also create your own command shortcuts in the file: {msr.cmdAlias.saveFolder}\msr-cmd-alias.doskeys
Every time after changes, auto effect for new console/terminal. Run `update-alias` to update current terminal immediately.
See + Use command alias(shortcut) in `MSR-RUN-CMD` on `TERMINAL` tab, or start using in a new command window outside.
(if running `find-xxx` in vscode terminals, you can `click` the search results to open in vscode.)
Type commands below in a terminal/console after cooking doskeys/alias:
- Type
use-this-alias
to use project specific alias in terminal (when in a git repo folder).- Type
list-alias
to list all files (auto cooked when opening repos in vscode).
- Type
- Type
update-alias
to switch to general alias.
Open user settings, set msr.useGitIgnoreFile
= true
(or msr.{repo-folder-name}.useGitIgnoreFile
= true
)
- This use the
.gitignore
file only in top folder of the project, without other kinds/folders of git-ignore files. - Omit file/folder exemptions (like
!not-exclude.txt
) as default (will ignore such git exemptions).- Set
msr.omitGitIgnoreExemptions
=false
to not use git-ignore if found exemptions.
- Set
- Auto detect and include(search) dot-folders like
".submodules"
by configmsr.ignorableDotFolderNameRegex
.
Parsing result of .gitignore
file: see MSR-Def-Ref
output channel (with msr.debug
= true
or launched in debug mode).
Run command "npm run test"
in vscode-msr folder if you want to see the translation rule of git-ignore on Windows/Linux/MacOS/FreeBSD.
- Method-1: Set
msr.autoCompareFileListsIfUsedGitIgnore
=true
to auto compare file list at starting (opening projects). - Method-2: Use menu/command-palette of
msr.compareFileListsWithGitIgnore
to compare file lists if enabledmsr.useGitIgnoreFile
.
- For all projects: Set
msr.useGitIgnoreFile
totrue
orfalse
. - For one project: Add
msr.{repo-folder-name}.useGitIgnoreFile
=true
orfalse
in user settings.
You can add custom search/replace command by adding config msr.xxx.myFindOrReplaceSelectedTextCommand
in user settings.json.
- Example of using git file list to precisely search
C++
code to find pure reference ofselected
text (%1
):- "msr.cpp.myFindOrReplaceSelectedTextCommand" =
"%UseGitFileListToSearch% -f \"\\.(c\\+\\+|cpp|cxx|cc|c)$\" --nt \"^\\s*(#include|/|\\*)|^.{360,}\" -t \"\\b%1\\b\" --xp test,mock,deprecate"
- Or write your own raw command for msr.cpp.myFindOrReplaceSelectedTextCommand =
"git ls-files --recurse-submodules > /tmp/tmp-git-file-list && msr --no-check -w /tmp/tmp-git-file-list ..."
- "msr.cpp.myFindOrReplaceSelectedTextCommand" =
- Recommended examples using
%AutoDecideSkipFolderToSearch%
+%FileExt%
/%FileExtMap%
:- "msr.cpp.myFindOrReplaceSelectedTextCommand" =
"%AutoDecideSkipFolderToSearch% -f %FileExtMap% -t \"\\b%1\\b\" ..."
- "msr.
{my-repo}
.txt.myFindOrReplaceSelectedTextCommand" ="%AutoDecideSkipFolderToSearch% -f \"\\.c[px]*$\" -t %SelectedWordVariation% ..."
- "msr.cpp.myFindOrReplaceSelectedTextCommand" =
%FileExtMap%
= Extensions like"\\.(c\\+\\+|cpp|cxx|cc|c)$"
in config or overrode by your settings.%FileExt%
= Current file extension like"\\.cpp$"
(the extension of current file in vscode).%1
= Placeholder of selected text in vscode.%UseGitFileListToSearch%
="git ls-files --recurse-submodules > /tmp/tmp-git-file-list && msr --no-check -w /tmp/tmp-git-file-list"
%ProjectsFolders%
=- Current path(
"."
) - if it's a single project/workspace. - Absolute paths of all projects/workspaces in current vscode, separated by comma(
","
).
- Current path(
%Skip_Junk_Paths%
= Skip_Junk_Paths environment variable inMSR-RUN-CMD
of vscode (if enabled git-ignore and no exemptions or omitted exemptions).- Will be replaced to
$Skip_Junk_Paths
on Linux/MacOS/FreeBSD.
- Will be replaced to
%AutoDecideSkipFolderToSearch%
=- if ignored/no git-exemptions.
msr -rp %ProjectsFolders%" --np "%Skip_Junk_Paths%"
- Otherwise:
%UseGitFileListToSearch%
(see above).
- if ignored/no git-exemptions.
%SelectedWordVariation%
= Replace selected text%1
like below (a bit similar with configmsr.reference.autoChangeSearchWord
):- Example: Mouse selection text =
m_product_id
will search code repo with Regex:\b(m_product_id|is_product_id|get_product_id|set_product_id|has_product_id)\b
- Example: Mouse selection text =
getProductId
will search code repo with Regex:\b(getProductId|productId|isProductId|setProductId|hasProductId)\b
- Example: Mouse selection text =
ProductId
will search code repo with Regex:\b(ProductId|productId|isProductId|getProductId|setProductId|hasProductId)\b
- Example: Mouse selection text =
GetProductId
will search code repo with Regex:\b(GetProductId|ProductId|IsProductId|SetProductId|HasProductId)\b
- Example: Mouse selection text =
- You can set any other command lines like below using
find-xxx
or gfind-xxx:"gfind-file -t \"^\\s*struct\\s+%1\\b\" -f %FileExt% -t \"\\b%1\\b\" ..."
"msr -rp %ProjectsFolders% --np \"%Skip_Junk_Paths%\" -f %FileExtMap% -t \"\\b%1\\b\" ..."
- You can hide the custom search menu by unchecking/setting
msr.myFindOrReplaceSelectedTextCommand.menu.visible
=true
in user settings. - The override rule of config is same with full priority rule like below (from high to low priority):
- msr.my-repo-folder-name.proto.myFindOrReplaceSelectedTextCommand
- Concrete
{Ext}
=proto
override below.
- Concrete
- msr.bp.myFindOrReplaceSelectedTextCommand
- General
{ExtMap}
=bp
=bond
+proto
.
- General
- msr.my-repo-folder-name.proto.myFindOrReplaceSelectedTextCommand
- Method-1: Use multiple workspace
- Add workspace for each repository in vscode, to have specific git-ignore for each repository.
- Recommended if you want to see the related/dependency files in vscode.
- Method-2: Use extra search paths
- Searches extra paths as final resort.
- Recommended if you don't want to see the related/dependency files in vscode..
If you want to support unknown languages, do anyone of below:
- Set
msr.enable.onlyFindDefinitionForKnownLanguages
= false in settings.json or un-check it in user settings UI. - See Easy to Support New Languages to add one or two config values.
Currently support well for: C#
, C++/C
, Python
, PowerShell
, Batch/Bash
, Java
, etc.
vscode-msr disabled itself finding definition for some languages which has good official extension support:
- Change config msr.default.autoDisableFindDefinitionPattern as your need.
- You can temporarily toggle enabling this extension when official extension got problems.
- Permanently update: Change msr.disable.extensionPattern value.
Two methods to support a new language. (If you're a developer/contributor see here, welcome!)
Open your personal settings file with code
or other tools like:
- Windows: code
%APPDATA%\Code\User\settings.json
- Linux: code
$HOME/.config/Code/User/settings.json
Take finding definition for batch files (*.bat
and *.cmd
) as an example (for normal users):
If you only want to support finding definition
for *.bat
files other than all batch
script (*.bat
+ *.cmd
):
Add lower case extension name
: "msr.{extension}.definition" (here {extension}
= bat ) into settings.json:
"msr.bat.definition": "^\\s*:\\s*(%1)\\b|(^|\\s)set\\s+(/a\\s+)?\\\"?(%1)="
See here if you're interested about the explanation of the definition
Regex used above and below.
- Add lower case
language name
as you want: "msr.fileExtensionMap.{Name}
" (here{Name}
= batch ) into settings.json:
"msr.fileExtensionMap.batch": "bat cmd"
- Add Regex match pattern to find definition (lower case name
msr.batch.definition
):
"msr.batch.definition": "^\\s*:\\s*(%1)\\b|(^|\\s)set\\s+(/a\\s+)?\\\"?(%1)="
Change/Add file extension names to config msr.fileExtensionMapNames
:
- Examples like:
"go py sql php md json xml"
- This will generate finding alias like:
find-go
/find-go-ref
/find-go-def
find-py
/find-py-ref
/find-py-def
find-json
/find-json-ref
- This will generate finding alias like:
- Ignore if found
msr.fileExtensionMap.xxx
likemsr.fileExtensionMap.cs
.
For example of Rust
language, adding msr.fileExtensionMap.rs
= "rs"
(like "bat cmd"
for msr.fileExtensionMap.batch
):
- You'll get new command shortcuts like:
find-rs
+find-rs-ref
+find-rs-def
to help search/replace or code mining. - This will use the default finding Regex patterns unless you added
Rust
patterns (seemsr.batch.definition
/msr.cs.class.definition
). - Please re-cook default/general shortcuts to avoid missing
default
shortcuts when switching fromproject-specific
shortcuts.
Set msr.quiet
= false
, msr.debug
= true
will help you tune and debug the config values (Regex patterns).
See optional settings and overriding rule.
Default setting just shows a few of 24 provided context menu items of Plain-text find
+ Regex find
+ Sort
.
To show or hide more menus, open user settings check/un-check menus like screenshot below:
Set msr.menu.visible
= false
to hide all context menus of Regex find xxx
+ Find xxx
etc.
-
Most time official extension(like
vscode-java
) works well, sovscode-msr
willdisable
itself finding definition:- If found professional extension process is running:
vscode-msr
will ignore"Go To Definition"
frommouse-click
orkey
likeF12
.
- You can still use
vscode-msr
by menu or terminal.
- If found professional extension process is running:
-
If official extension not work, you can
toggle
enablingvscode-msr
temporarily (until reload).
- Default config =
msr.cpp.autoDisableFindDefinitionPattern
, values is a Regex pattern of process name of professional language extension (likevscode-java
). - If you don't want to use this auto-disabling feature, like below (update user settings):
- For
C++
, add/set empty valuemsr.cpp.autoDisableFindDefinitionPattern
=""
. - For all languages, add/set empty value
msr.default.autoDisableFindDefinitionPattern
=""
- Change config like
msr.java.autoDisableFindDefinitionPattern
to empty if found.
- Change config like
- For
- Accelerate/accurate checking language process like below(
C#
+Rust
):msr.cs.languageProcessName
=dotnet
msr.rs.languageProcessName
=rust-analyzer
- For mapped extension (like:
cs
/rs
/py
/cpp
/java
):- Check
msr.fileExtensionMap.xxx
likemsr.fileExtensionMap.cs
. - You can add more
msr.fileExtensionMap.xxx
.
- Check
For 2 cases when "Go To Definition"
by menu or key(F12
) or "Ctrl + Mouse Left Click"
:
- Got duplicate results (from both
vscode-msr
+ official extension likevscode-python
). - No results found if you disabled
vscode-msr
via menu or hot-key of"Toggle enable/disable msr"
.
Then just press Alt+F2
to temporarily toggle Enable
/Disable
of Finding Definition
. Change Alt+F2
if hot-keys conflict.
It's useful when the official/professional plugins got problems:
- Temporarily enable
vscode-msr
when the official language plugins fail. - Temporarily disable
vscode-msr
when the official language plugins work well.
Note for the toggle
:
- See workaround if you encounter cases like error impact of
vscode-python
+vscode-powershell
to vscode. - Only impact
"find definition"
, you can still search or replace by menus or command shortcuts. - This is effective until you reload or restart current vscode window. (Permanent changes see settings below.)
This temporarily ignores all other settings like below to enable/disable finding for a language:
msr.enable.onlyFindDefinitionForKnownLanguages
- Known language type means exist "msr.fileExtensionMap.{name}" like "msr.fileExtensionMap.python".
msr.disable.extensionPattern
msr.disable.findDef.extensionPattern
msr.disable.projectRepoFolderNamePattern
There're another 2 ways to toggle besides the hot key (Alt+F2
):
- Command Palette: Press
F1
to open command palette, then typemsr temp
ormsr toggle
etc. - Right-Pop-Menu: Change
msr.tmpToggleEnableFindingDefinition.menu.visible
then use it.
Set quiet mode if you don't want to activate vscode tabs like OUTPUT
and TERMINAL
.
-
msr.disable.extensionPattern
Regex pattern of file name extensions to disable
find definition and references
.For example:
- Set
tsx?|jsx?
forTypeScript
andJavaScript
files. - Set
py|cs|java|scala
forpython
,C#
andJava
/Scala
files .
- Set
msr.disable.findDef.extensionPattern
like tsx?|jsx?|go|py
msr.disable.findRef.extensionPattern
like tsx?|jsx?|go|py
-
msr.disable.projectRepoFolderNamePattern
(case sensitive)Regex pattern of
git root folder name
to disablefind definition and references
functions for specific projects.For example:
^(Project\d+)$
to disable for D:\Project1 and C:\git\Project2.
msr.enable.definition
: Set tofalse
or un-check it to disablefind definitions
function for all types of files.msr.enable.reference
: Set tofalse
or un-check it to disablefind references
function for all types of files.
- Default: Output forward slash('/') on Windows terminals (like
CMD
) by settingMSR_UNIX_SLASH=1
. - To restore backslash('\') on Windows:
- Change
MSR_UNIX_SLASH=0
or change it in configmsr.cmd.postInitTerminalCommandLine
.
- Change
- For cooking command alias/shortcuts and using it:
msr.cookCmdAlias.outputFullPath
msr.cookCmdAlias.outputRelativePathForLinuxTerminalsOnWindows
:
- For search output (from
menu
orauto-triggered re-run when got multiple results
):msr.searchRelativePathForLinuxTerminalsOnWindows
:- Set
true
to help click + open results invscode
for Cygwin/MinGW/WSL terminals on Windows.
- Set
msr.searchRelativePathForNativeTerminals
: Enable it to get short paths.
- Just add
-W
to output full paths when you re-use the command line and if it output relative paths.
This doc listed a few configuration names. Finding more by pressing F1
to Open User settings to change.
- Default
msr.quiet
=true
to not activate/showMSR-Def-Ref
(inOUTPUT
tab) +MSR-RUN-CMD
(inTERMINAL
tab).MSR-Def-Ref
shows sorted results after ranking, and specific search commands with time costs.MSR-RUN-CMD
showsre-running search when got multiple results
orfinding commands from menu
.
-
Usually you don't need to change user settings, however, when necessary:
- Type/paste
msr.xxx
in vscode UI(like below) or add/updatemsr.xxx
in user settings file:
- Type/paste
-
You can add
msr.{repo-folder-name}.xxx
in settings file to override all config values, like:msr.{repo-folder-name}.useGitIgnoreFile
ormsr.{repo-folder-name}.skipFolders
etc.
-
Full priority/order: See overriding rule + order.
Note: Check your personal settings (msr.xxx
in file) with the latest tuned github settings, especially for Regex
patterns.
In above config name example msr.{repo-folder-name}.xxx
(add into user settings file):
- Key
{repo-folder-name}
= git repository folder name (likemy-project
forD:\code\my-project
) - Key must matches Regex
"^([\w\.-]+)$"
:- You can simply test it like command below (will print
"Matched"
):- msr -t
"^([\w\.-]+)$"
-zmy-project_2.1
- msr -t
- The valid(trimmed) name is also auto displayed in project-alias-file path in vscode terminals.
- You can simply test it like command below (will print
msr.default.maxSearchDepth
: Setmax search depth
when finding definitions or references.msr.default.codeFiles
: Setdefault
Regex pattern forsource code files
.msr.descendingSortForVSCode
: Descending sort search results forvscode
.msr.descendingSortForConsoleOutput
: Descending sort search results for output channel invscode
bottom.msr.default.skipFolders
: Setdefault
/common
skip folders Regex pattern.msr.default.removeLowScoreResultsFactor
: Default threshold =0.8
(of max score) to remove low score results.msr.default.keepHighScoreResultCount
: Default count = -1 (keep all) to keep top high score results.
-
Default behavior(change user settings as you wish):
msr.initProjectCmdAliasForNewTerminals
=true
- Auto set/initialize command alias/doskeys for newly created terminals:
msr.skipInitCmdAliasForNewTerminalTitleRegex
=PowerShell\\s*Integrated\\s*Console|pwsh$|Java|Debug
- Not set/initialize command alias/doskeys for terminals of
PowerShell Integrated Console
andLinux PowerShell
etc.
- Not set/initialize command alias/doskeys for terminals of
-
Merge project specific
excluded folders
from.vscode/settings.json
in each project root folder.- Extract folders from
files.exclude
andsearch.exclude
by Regex:^[\w-]+$
after trimming*
at head and tail. - You can disable
msr.autoMergeSkipFolders
to not auto merge excluded folders. - You can disable
msr.overwriteProjectCmdAliasForNewTerminals
to use the existing temp command shortcuts of each project.
- Extract folders from
-
Auto switch to
CMD
console other thanPowershell
on Windows to use command shortcuts.- Due to
Powershell
cannot usedoskey
command shortcuts. (You can cook command script files then add the script folder to%PATH%
or$PATH
)
- Due to
Default: Auto run use-this-alias
+ restore environment variables for "History restored"
terminals - due to vscode lost them.
- Change config
msr.autoRestoreEnvAliasTerminalNameRegex
to disable/enable auto runninguse-this-alias
+postInitTerminalCommandLine
for restored terminals.
Supported various types of terminals: (settings file like: %APPDATA%\Code\User\settings.json
on Windows).
Not recommend to set terminal type after vscode 1.56, which is unnecessary since easier to open different terminals.
Only explicitly set terminal
on Windows when you caught problems like unable to determine PowerShell
or CMD
type.
- VsCode Official supported terminals like below:
// CMD console:
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe"
// Git Bash(MinGW): Built-in environment variable: MSYSTEM like: MSYSTEM=MINGW64
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe"
// Ubuntu Bash on Windows (WSL):
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\bash.exe"
- Additionally supported by vscode-msr: Cygwin (green install), you can set in your personal settings file like:
// Cygwin Bash. One command to install Cygwin (into a folder no pollution): https://github.com/qualiu/msrTools/blob/master/system/install-cygwin.bat
For Cygwin as main terminal (may obsolete):
"terminal.integrated.shell.windows": "D:\\cygwin64\\bin\\bash.exe"
For Cygwin integration:
"terminal.integrated.profiles.windows": {
"Cygwin": {
// "path": "D:\\cygwin64\\Cygwin.bat" // Unable to auto init command alias
"path": "D:\\my-tools\\cygwin-bash.bat" // Any path contains word 'cygwin' to help identify Cygwin terminal
}
}
}
The cygwin-bash.bat content example like below (assume your cygwin at D:\cygwin64):
@REM call d:\my-tools\msrTools\disable-exe-in-PATH.bat grep.exe || exit /b -1
@set CYGWIN_ROOT=D:\cygwin64
@set "PATH=D:\cygwin64\bin;%PATH%"
@bash %*
Set /etc/wsl.conf like below to use short mount paths (like /c/
instead of /mnt/c/
), may need restart to effect:
[automount]
root = /
options = "metadata"
After changed mounting style from /mnt/c/
to /c/
, you can click + locate file paths in vscode (and other IDEs).
You may need fuzzy code searching for cases like below:
- Only got piece of words from others, just human language not the exact name of code (
class
/method
). - Take over a project, or already ramp-up for several days, not easy to get help.
Then you can try code/knowledge mining by yourself with vscode-msr: (after cooking doskey/alias if out of vscode)
Besides the normal "Go To Definition"
by menu or key(F12
), you can take flexible code mining in vscode terminals/console.
The 40+ shortcuts like find-xxx
are convenient wrappers of msr/nin with 70+/30+ composable optional-args (brief Quick-Start at bottom of running msr -h
or nin -h
).
Code mining examples (run in vscode terminals: like MSR-RUN-CMD
or add/open new terminals):
-
Fuzzy search a class/method: (Try gfind-xxx for precise searching + rgfind-xxx for multi-repos)
- find-def
"\w*Keyword\w*You-Heard-or-Knew\w*"
-i- gfind-def
"\w*Keyword\w*You-Heard-or-Knew\w*"
-xclass
--sp"/common/,/lib"
- gfind-def
"\w*Keyword\w*You-Heard-or-Knew\w*"
-xstruct
-k12
- gfind-def
- find-def
-
Fuzzy search a class/method, with optional args like ignore case(-i) :
- find-cpp-def
"\w*Keyword\w*"
-i - find-cpp-ref
"\w*Keyword\w*"
-i -xclass
--xp"test,mock,/obj,/bin/"
- find-ref
"class\s+\w*Keyword\w*"
-i --nx";"
--spsrc/,/lib/
- gfind-java-ref
"class\s+\w*Keyword\w*"
-i --nt";\s*$"
- gfind-java-ref
"\w*Keyword\w*"
-i -xclass
- gfind-java-ref
- find-all -i -t
"class\s+\w*keyword\w*"
- find-cs-def
"\w*Keyword\w*"
-i -xenum
- find-cs-def
"\w*Keyword\w*"
-ixpublic
-H20
-T20
--nxinternal
-d"^(src)$|keyword"
--nd"test|^(unit|bin$)|demo"
- find-py-def
"\w*Keyword\w*"
-i --nt"private|protected"
--pp"/src/|keyword"
--xptest,/unit,/bin/,demo
--np"test|/unit|/bin/"
- find-py-def
"\w*Keyword\w*"
-i --nxprivate
--nt"protected|internal"
--xptest,/unit,/bin/,demo
--pp"/src/|keyword"
-H 20 -J ...
- find-cpp-def
-
Replace File Text: Add -o
"replace-to-xxx"
+ Append -R toreplace
(Preview replacing result without-R
):- find-ref
OldName
-oNewName
-Lrow1
-Nrow2
--nt ... --nx ... --sp ... -xp ... --pp ...- gfind-ref
OldName
-oNewName
-x"And has text"
--nt ... --nx ... --sp ... -xp ... --pp ... - gfind-java-ref
OldName
-oNewName
-x ... --nt ... --nx ... --sp ... -xp ... --pp ... - gfind-file -t
"\bOld Text\b"
-o"New Text"
-j -- to preview only changed replacing.
- gfind-ref
- gfind-config -t ... -o ...
- gfind-small -t ... -o ...
- find-ref
-
Accelerate searching if you know the language type (like
Python
/C#
), the more filters the faster:- find-py-def
"\w*(get|set|update)\w*Method-Keyword-You-Heard\w*"
-ixpublic
--nx ... --nt ... --xp ... --sp ... --pp ... --np ... -d ... --nd ... - find-cs-def
"\w*(get|set|update)\w*Method-Keyword-You-Heard\w*"
-i - find-cpp-ref
"(class|enum)\s+\w*Class-Keyword-You-Heard\w*"
-i - find-java-ref
"(class|enum)\s+\w*Class-Keyword-You-Heard\w*"
-i - find-go-ref
"\w*Class-Keyword-You-Heard\w*"
-i -xclass
- find-ui -it
"regex-pattern"
-x"and-plain-text"
- find-code -it
"(class|enum)\s+\w*Class-Keyword-You-Heard\w*"
- find-all -i -t
"(class|enum)\s+\w*Class-Keyword-You-Heard\w*"
- find-cpp-member-ref
m_variable
-- to findm_variable
+getVariable
+setVariable
+_variable
+variable_
- gfind-cpp-member-ref
m_variable
-xset
-- to findsetVariable
- gfind-cpp-member-ref
- find-spring-ref
setVariable
-- to findvariable
+getVariable
+setVariable
- find-spring-ref
variable
-xis
-- to findisVariable
- find-spring-ref
- find-py-def
-
Others like: (run command
alias find-xxx
to see the command template likealias find-all
)- find-doc -it
"regex-pattern"
-x"and-plain-text"
--nx ... --nt ... --xp ... --sp ... --pp ... -d ... --nd ... - find-config -it
"regex-pattern"
-x"and-plain-text"
- find-small -it
"regex-pattern"
-x"and-plain-text"
- find-doc -it
-
General finding commands like:
- find-nd -it
"regex-pattern"
-x"and-plain-text"
optional args - find-nd -f
"\.(cs|py|java)$"
-it"regex-pattern"
-x"and-plain-text"
- find-ndp
path1,path2,pathN
-f"\.(cs|py|java)$"
-it"regex-pattern"
-x"and-plain-text"
- find-ndp
path1,path2,pathN
-it"regex-pattern"
-x"and-plain-text"
... - find-file -it
"regex-pattern"
--sp"sub-path1/,/sub-path2/"
- find-file -it
"regex-pattern"
-x"and-plain-text"
--s1100KB
--s23.5MB
-f ... - gfind-file / gfind-all / gfind-small / gfind-ref / ...
- find-nd -it
-
With other optional args like:
- find-all -it
"regex-pattern"
-x"and-plain-text"
-l just list matched file paths. - find-all -x
"and-plain-text"
-it"regex-pattern"
-o"replace-regex-to-this"
-R replace file text - find-all -it
"regex-pattern"
-x"and-plain-text"
-o"replace-plain-text-to-this"
-R replace file text - find-all -it
"regex-pattern"
-x"and-plain-text"
-U 5 -D 3 -H 100 -c Output100 lines
with5-rows-up
+3-rows-down
for each match. - find-all -it
"regex-pattern"
-x"and-plain-text"
--nx"not-contain-text"
--nt"not-match-regex"
--xp/bin/,debug/,test
--ppexpected-path-regex
--npskip-path-regex
-U 3 -D 2 -H 100 -T 100 ...
- find-all -it
-
Other functions:
- find-top-source-type
-H 9
: Gettop 9
language types by file count/percentage in current workspace/repository. - find-top-source-type
-k 100
: Get top languages which filecount >= 100
. - find-top-source-type
-K 2.5
: Get top languages which file countpercentage >= 2.5%
. - find-top-type -H 9
-w
: Get top 9 file types and show one example file path (whole/full
path) of each type. - sort-source-by-time
-T 9
: Getnewest 9 source files
sortingsource files
by file write/modify time. - sort-by-time
-T 9
: Getnewest 9 files
sortingall files
by file write/modify time. - sort-by-size
-T 9
: Getnewest 9 files
sortingall files
by file size. - sort-by-size -T 9
-W
: Getnewest 9 files
sortingall files
by file size + Showfull paths
(absolute paths).
- find-top-source-type
Once you found the results:
- You can filter results by appending filters. (Add
-c
to see full command line or debug). - Click + open the search results in vscode and continue your code mining.
- Search code together with official vscode extensions (like:
vscode-python
/vscode-go
) + official IDEs (like:Visual Studio
/PyCharm
).
Additional Settings in Your Personal Settings file
-
Set
skipFolders
for Specific ProjectYou can set
skipFolders
pattern for each project to overwritedefault.skipFolders
in your personal settings file.Like adding
msr.{repo-folder-name}.skipFolders
+ value in%APPDATA%\Code\User\settings.json
on Windows:"msr.My-Project-Repo-Folder-Name.skipFolders": "^(unit|tests)$|other-partial-folder-name"
-
Promote Scores for Specific Project Folders or Paths
Set below items if you need in your personal settings file like
%APPDATA%\Code\User\settings.json
on Windows.Regex pattern to promote scores for sorting definition (
Go To Definition
) or references (Find All References
):msr.{repo-folder-name}.promoteFolderPattern
: Regex pattern to promote folder scores for result file folders.msr.{repo-folder-name}.promotePathPattern
: Regex pattern to promote path scores for result file paths.msr.{repo-folder-name}.promoteFolderScore
: Recommended value is 100 to 1000. Default = 200 if not set.msr.{repo-folder-name}.promotePathScore
: Recommended value is 100 to 1000. Default = 200 if not set.
msr.default.extraSearchPaths
: Extra search paths of external repositories, dependency sources, or libraries, etc.msr.default.extraSearchPathListFiles
: Read extra search path list files of external repositories, dependency sources, or libraries, etc.
These global extra search paths settings enable searching related files without loading them into vscode
.
More details see Extra Path Settings.
msr.fileExtensionMap.batch
: Set file extension of batch script (*.bat
+*.cmd
), value ="bat cmd"
.msr.fileExtensionMap.rs
: Support new language (Rust
), value ="rs"
.msr.cpp.codeAndConfigDocs
: Regex pattern ofC++
/C
code + configuration + document files.msr.py.extraSearchPaths
: Extra search paths forPython
code's external repositories, dependency sources, or libraries, etc.
Normal Search (default context menu
) + Extensive Search (context menu
+ command palette
)
- Normal search:
- Find definition (
Go to Definition
menu): Precise search project root + extra paths if set. - Find references (
Find All References
menu): Disabled by default (Use menus like"Regex find xxx"
menus or use shortcuts like code-mining).
- Find definition (
- Extensive search:
- Plain-text and Regex searching groups in command palette and partially in editor context menu (
Find plain text in xxx
orRegex find xxx
) - Provide specific searching in project root + extra paths if set. For example,
Regex find pure references in code files
will skip comments and long text in code.
- Plain-text and Regex searching groups in command palette and partially in editor context menu (
You can reuse msr original search command line
in vscode
output channel MSR-Def-Ref
or terminal MSR-RUN-CMD
to search + replace files.
More details see: Scenario Glance.
You can use any 1 of 3 methods below to filter results or take further searches:
- Leverage
original search command line
inMSR-Def-Ref
orMSR-RUN-CMD
, and change/tune. - Use command shortcuts to write brief searching/replacing commands in/out-of vscode:
MSR-RUN-CMD
+ other terminals in vscode after auto-initializeddoskey/alias
.- System console (like CMD/Bash) out of vscode: See switch general/specific shortcuts.
- Write raw msr/nin commands with 70+/30+ composable optional-args (brief Quick-Start at bottom of running
msr -h
ornin -h
).
Change the value of -t / --np / --nd if already used in command line.
- Filter result text:
- -x
"need plain text"
, --nx"exclude plain-text"
- -t
"search/include Regex"
, --nt"exclude Regex"
- -x
- Filter result file name, folder, full-path:
- -d
"match folders Regex"
, --nd"exclude folder Regex"
- --pp
"full path Regex"
, --np"exclude full path Regex"
- --sp
src/,/lib/,common/,.cpp
, --xp"/full-paths,or/sub-paths,sub-path-text,.hpp"
- -d
- You can also add more
msr
commands to the command line like:msr original command
|msr -i -t "^\s*public" -P -A -C
- Get matched file
list
(-l) -> Generate commands (-omsr xxx
) -> Execute commands (-X):msr original command
-l -PAC |msr -t "(.+)" -o "msr -p \1 -t \"class To-Search\" xxx"
-X
- More advanced search like: Execute(-X) + Only output matched command(-O) + No summary(-M)
command lines
| msr -X -M -O --to-stderr- Same with -XMO; Use to-stderr to redirect command lines info to stderr.
- Use -P to hide beginning command lines like: -XPM or -X -P -M.
- Use -I to hide end(return) command lines like: -XMI or -X -M -I.
Reuse the search command above (or find-reference
command line in vscode
), you can also write a new command.
- See replaced text lines (add -o
replace-to-text
):msr original command ... -t "xxx" ...
-o"replace-to"
- Just preview changed files (-j):
msr original command ... -t "xxx" ...
-o"replace-to"
-j
- Replace file text (-R):
msr original command ... -t "xxx" ...
-o"replace-to"
-R- Add -K if you want to backup changed files.
- Add --force to replace file text with
BOM
header notUTF-8 0xEFBBBF
.
Besides the overview doc and readme.txt here's brief summary(try msrUI if built-in help not good enough):
- Easy to add, update or tune
Regex
patterns to improve existing or support new coding languages:- Use above debugging method with the output info.
- To test or tune your
Regex
patterns: Use the auto-downloaded tool msr of your system type to test like:- Input a string from input-arg (
-z
) or pipe (likeecho
):- msr -z
"class CPP_EXPORT MatchThisCppClass"
-t"^\s*class (\w+\s+)?\bMatchThisCppClass"
- echo
class CPP_EXPORT MatchThisCppClass
|
msr -t"^\s*class (\w+\s+)?\bMatchThisCppClass"
- msr -z
- Input a file like:
- msr -p
my-class.hpp
-t"^\s*class (\w+\s+)?\bMatchThisCppClass"
- msr -p
- Input paths and recursively search like:
- msr -r -p
my-class.hpp,src,folder2
-t"^\s*class (\w+\s+)?\bMatchThisCppClass"
- msr -r -p
- Input a string from input-arg (
- Use the rich searching options of msr-EXE like below, combine these optional options (You Can Use All):
- Set searching paths: (Can use both)
- Recursively(
-r
) search one or more files or directories, like: -r -pfile1,folder2,file2,folder3,folderN
- Read paths (path list) from files, like: -w
path-list-1.txt,path-list-2.txt
- Recursively(
- Set max search depth (begin from input folder), like: -k
16
(default max search depth =33
). - Filter text by
line-matching
(default) orwhole-file-text-matching
(add -S / --single-line Regex mode):- Ignore case:
- Add -i (
--ignore-case
)
- Add -i (
- Regex patterns:
- -t
should-match-Regex-pattern
- --nt
should-not-match-Regex-pattern
- -t
- Plain text:
- -x
should-contain-plain-text
- --nx
should-not-contain-plain-text
- -x
- Ignore case:
- Filter
file name
: -fshould-match-Regex
, --nfshould-not-match
- Filter
directory name
: -dat-least-one-match
, --ndnone-should-match
- Filter
full path pattern
: --ppshould-match
, --npshould-not-match
- Skip/Exclude link files: --xf
- Skip/Exclude link folders: --xd
- Skip full or sub paths: --xp
d:\win\dir,my\sub,\bin\
- Newer msr supports forward slash(
/
) on Windows to ease slash-escaping:- --xp
d:/win/dir,my/sub,/bin/
same asd:\win\dir,my\sub,\bin\
- (You can omit double quotes since no spaces and special characters).
- --sp
common/,lib/
same ascommon\,lib\
- --np
"d:/win/dir|my/sub|/bin/"
same as"d:\\win\\dir|my\\sub|\\bin\\\\"
- (Need more slashes if end with a slash + double quote).
- --pp
"/src/|/common"
same as"\\src\\|\\common"
.
- --xp
- Check if your msr support forward slash(
/
) by command:msr -h | msr -x "Support '/'"
- Newer msr supports forward slash(
- Try to read once for link files: -G (link files' folders must be or under input root paths of
-p
or/and-w
) - Filter
file size
: --s1 <= size <= s2 , like set one or two: --s11B
--s21.5MB
- Filter
file time
: like --w12019-07
, --w2"2019-07-16 13:20"
or2019-07-16T13:20:01
(quote it if has spaces). - Filter rows by begin + end row numbers: like -L 10 -N 200 (for each file).
- Filter rows by begin + end Regex: like -b
"^\s*public.*?class"
-q"^\s*\}\s*$"
- Filter rows by 1 or more blocks: -b
"^\s*public.*?class"
-Q"^\s*\}\s*$"
- Filter rows by 1 or more blocks + stop like: -b
"^\s*public.*?class"
-Q"^\s*\}\s*$"
-q"stop-matching-regex"
- Quickly pick up
head{N}
results + Jump out(-J
), like: -H30
-J or -J -H300
or -JH300
etc. - Don't color matched text: -C (
Faster
to output, and must be set forLinux/Cygwin
to further process). - Output summary
info
to stderr + hidewarnings in stderr
(like BOM encoding): -I : You can see -I -C or -IC or -J -I -C or -JIC etc. in package.json
- Set searching paths: (Can use both)
Github repository: https://github.com/qualiu/vscode-msr
You may just need to add or update the configuration file: Add or update Regex
patterns of find-references
or find-definitions
for various coding languages.
Please help to set the Regex
patterns for them if you want. You can:
- Reference the
.definition
and.reference
Regex patterns of default or a specific language type in configuration file. - Debug this extension:
- Use
vscode
to open this project start (pressF5
) to debug, if you've cloned it. - Set/Check
msr.debug
to enable output debugging info, if you just installed this extension.
- Use
- See the docs here or on msr.
-
npm run test
to check configurations. -
nin package.json nul -p -d -k 2 -x description -c Should no unreasonable duplicate descriptions.
For example, it may slower than usual if the disk (where code files stored) is busy, or slower than expected if the hardware is too old, or CPU is too busy.
Long existing VsCode Bug: Unable to jump to definitions sometimes
+ Duplicate definition + reference results
.
It's better to be solved by vscode
itself to remove final duplicate results, or provide an interface for extensions to do it.
However, there're 2 workarounds for finding definition as below:
- Method-1: Set msr.quiet = false: Un-check it from user settings, which is opposite to Set Quiet Mode.
- This let you see
sorted results after ranking
and able to click and go to the locations. - But this may annoy you to activate and show 2 channels each time
"Go To Definition"
:- It'll show search command + results in the
MSR-Def-Ref
channel inOUTPUT
tab each time. - And re-run search in
MSR-RUN-CMD
inTERMINAL
tab ifgot multiple results
orno results found
.
- It'll show search command + results in the
- The best scenario of this method is probably when you're
"just reviewing or reading code"
.
- This let you see
- Method-2: Set msr.reRunSearchInTerminalIfResultsMoreThan = 0 (default =1).
- This is more quiet: It won't activate the channels and tabs above.
- This just re-run the search command in
MSR-RUN-CMD
channel inTERMINAL
tab to let you click and go. - You can also re-use the commands, add some options to filter your search or replace file text.
- But you can only see them when when
MSR-RUN-CMD
is the active window(terminal).
Due to both "Peek Definition" and "Go to Definition" were triggered:
- Peek Definition was triggered by
Ctrl
+Mouse hover
. - Go to Definition was triggered by
Ctrl
+Mouse left click
.
You can use Ctrl + Mouse hover
to peek definition
, use F12
to go to definition
as a workaround.
-
Near-precise support: Will show multiple results for same name
classes/methods/etc
, due to this is a light tool without syntax parsing and cache. -
Near-precise support
class
,methods
,enum
,field
,property
for C#, Python, Java, Scala, C++ / C. -
Rough support
class
andmethod
for all type of languages (you can copy/write configurations follow existing languages).Welcome + Please help to improve searching definitions and references for
classes
andmethods
, and add supports forenum
,property
,field
etc.See easy to support new languages + add new support or improve.
See CHANGELOG or vscode-msr
extension commit history.
Enjoy!