Some text editors and IDEs have this feature that LISTS all the occurrences of a string and displays them as a list.
I have Googled this feature for VSCode, but what I got was mostly 'how to SELECT all occurrences'.
What I want is something like this (Notepad++):
One way to get this is to use the bundled ripgrep that comes with VS Code. You can find it under this path inside the folder your VS Code is installed to:
/resources/app/node_modules.asar.unpacked/#vscode/ripgrep/bin/rg
Just open a terminal pane in VS Code with a console of your choice and invoke that ripgrep executable with whatever query is appropriate for the search you want to perform.
You can read more about ripgrep and how to use it on its GitHub page: https://github.com/BurntSushi/ripgrep.
Related
Recently, I had to reinstall windows 11 on my machine. So, after that, I had to install VSCode again (therefore, I have the most recent version of VSCode).
Now, whenever I select any Persian sentences (strings) in my code, the IDE shows a messed-up string that is far away from the correct one. I can not show the correct and incorrect sentences as texts here because copying and pasting results in the correct format. Therefore, I have to provide them as images. (Sorry for any inconvenience, in advance)
Correct Persian Sentence
Incorrect Persian Sentence (After selecting)
This might be a little bit tricky to understand for people who are not familiar with the Persian Language. The difference can be understood by looking at the first word after $creatorId in both images.
This also might happen if we wanted to write in Arabic or other right-to-left languages.
It would be highly appreciated if you could suggest anything to avoid this.
After searching a lot, I found the proper answer on one of the VScode repository's issues. The problem was with the way the new version of VSCode renders the whitespace. So, to solve this problem, you need to follow the below steps:
Open VSCode command pallete by CTRL + SHIFT + p
Search for Open Settings (JSON) and click on it. It should open a JSON file named setting.
In this JSON file, add a key named editor.renderWhitespace and assign on of the following values to it: boundary, trailing or none. Your JSON file should look something like this:
{
"editor.renderWhitespace":"boundary"
}
The weird messed-up string is disapeared now.
Note
You can also access and change the editor.renderWhitespace using the settings editor. So, if you find the steps mentioned above frustrating, just use the settings editor (you can open it using the setting icon at the right end of the VSCode window or even using CTRL + ,) and search for editor.renderWhitespace. Then choose one of the three above-mentioned options.
Where can I find the list of all commands available in VSCode and their description?
I'm only aware of these sources:
In the official docs:
This list which only seems to include a subset of Visual Studio Code commands that you might use with vscode.commands.executeCommand API (why is this only a subset of the full list?)
This other list in the keybindings doc, which also only seems to include a subset of all commands available (I suppose those tied to a default keybinding?)
In the editor itself:
I can see a list of commands when I open the "default keybindings". Many actions are commented out with //, but interestingly I don't think this includes all the commands either (e.g. maximizeOtherEditor isn't listed)
Does VSCode have an official list of commands (commandID's) either in its documentation or in its code base? If not:
What's the closest to it?
What's a good way to navigate the code base to try to find all commands and what they do?
I believe that content of "Preferences: Default Keyboard Shortcuts (JSON)" (command ID workbench.action.openDefaultKeybindingsFile) really shows comprehensive list of all native and extensions-contributed commands VSC knows about at moment when invoked.
This file shows keys from VSC's defaults and extension manifests.
Commands with no suggested defaults are those commented out at the end of file.
Their descriptions (as seen in the Command Palette, Keyboard Shortcuts settings, extension Contributions tab and elsewhere) are supposedly in localization properties and I believe there is currently no way to see them along their respective command IDs in single convenient "localized" list. So for now the only way to read the description of command found in aforementioned JSON is pasting its ID into Keyboard Shortcuts search field. (Would be delighted to be proven wrong.)
In case someone ever fell on this and just wanted a quick-list of VSCode commands to browse through: https://gist.github.com/skfarhat/4e88ef386c93b9dceb98121d9457edbf
If you do, please note the VSCode version and commit. These may well be out of date by the time you read them.
I am exploring vscode after using atom for a long while. One of the things I'm missing is an equivalent of the lovely package advanced-open-file. Is there something similar to this in vscode?
I found the advanced-new-file extension, but it is only helpful when it comes to new files. I would like to be able to quickly open files from all over my local files (not only the workspace).
Edit: I found the option of workbench.action.quickOpen; but it doesn't allow opening files from the whole file system.
Sorry, but currently the answer is no. The problem is that input box doesn't provide a way to listen to key events:
GitHub issue,
so even the extensions can't do that currently. Here's the comment from advanced-new-file extension creator:
Because VSCode extensions don't yet have the ability to do type-ahead autocomplete within the text input box (See https://github.com/Microsoft/vscode/issues/426), we work around this limitation and provide autocomplete using a two-step workflow of selecting existing path, then providing new filename/path relative to the selection.
The good news is that there is a new API addressing this issue, but it's currently in 'proposed' state and can't be used for published extensions.
One workaround could be typing code -r some/path in integrated terminal and using 'tab' for autocomplete.
The Fuzzy search extension seems to work for me.
It adds a new action to the command palette which allows you to search for files in the current project and open them.
Here's a demonstration of the feature in IntelliJ (https://www.youtube.com/watch?v=EtnI2doW6XE)?
In case the video isn't viewable, basically the user presses a key-combo, and a dialog box pops up that will reactively response and filter based on the string the user starts to type in. It will show classes and files (and much more) matching what you've typed in. I won't go in to all the details, as I'm not looking for an exact match to this functionality -- I'd be happy if it just searched based on file name for starters! Anything to prevent me from having to browse for a filename in the project Explorer to open the file in vs code when I want to switch to the given file.
I saw How do I search for files in Visual Studio Code? - for me (on Linux) Ctrl-E just shows the file I currently have open under the project explorer (useful sometimes, but not what I'm looking for).
Cmd + P opens a search bar for files (doc),
Cmd + T opens a search bar for symbols (doc),
Are you just looking for CTRL-P That brings up a file list. Which is searchable. You can then tab down and right arrow opens up that file. Enter will open a split editor on the file.
Also, if you CTR-p and then type ? you will get a list of keys you can hit such as to "Go to Symbols" and much more in your file or workspace.
And look at CTRL-R it probably does exactly what you are looking for as far as files go.
Current palette # search only finds tags/variables in the current opened files, but in webstorm searches for a text in all code/files in your project as you type instantaneously, regardless of being a tag or variable, is there a tool/addon that does this in VS code? current search (Ctrl+shift+f) you have to press Enter and takes a while to get all the results.
Here is an example from webstorm
To get both files and symbols in quick open, try setting:
"search.quickOpen.includeSymbols": true
The symbol search results require language support. VS Code ships with support for JavaScript and TypeScript symbol search, but you'll need an extension to getting symbols for languages like php.
If an extension is only returning symbols for open documents instead of all documents in the workspace, please file an issue against them.
You can use a Quick Search command of this extension. As of VSCode 1.55, it still works (you'll have to install ripgrep though).
In 2021 you can use CMD+P to get a similar behaviour.