Is it possible to force Quick Open to take a query from the current selection in the editor? - visual-studio-code

The current editor I have open contains the name of a file or part of the name of a file that I have in my workspace. I want to search for that file by selecting the text of that name from the editor, and then putting that text in the Quick Open search box. Currently, I need to manually copy and paste the text, but I want to have behaviour similar to the cmd + F search box where the selected text from the editor immediately appears in the search bar when it is opened. Is it possible to configure Quick Open to do this as well? Or maybe there is an extension for this?

At the time of this writing, this is currently not configurable.
If you look in the settings, all the settings that allow enabling or disabling this behaviour contain the word "seed" in them: search.seedOnFocus, search.seedWithNearestWord, editor.find.seedSearchStringFromSelection. From my reading/searching, there is no other setting with the word "seed" in it.
I googled "github vscode issues quickopen seed" and found this GitHub feature-request on the VS Code GitHub repo: Fuzzy quick open should use selected text as a starting point #59957 asking for such behaviour to be the default behaviour. The issue didn't get enough support from other users to get added to their backlog (a feature request needs to get a certain number of thumbs up reactions from users within a certain time period after it is created to get considered for implementation), so that feature-request is now closed.
If you want to get such a configuration option, create a feature-request issue ticket. If you want to increase your feature-request's visibility (and therefore its chance of getting enough user support), share a link to it on various programming platforms such as r/vscode.
I didn't find any extensions that do this by googling "vscode marketplace quick open seed" and looking at the top results, but maybe you'll have better luck with different queries.

Related

VSCode Find / Replace History

New to VSCode and notice there's not a dropdown history of previous find/replace strings. I am also striking out on finding this functionality via extensions.
Most every editor I've ever used has had this, so I find its absence conspicuous.
I see exact and similar feature requests on github, but alas it could never get the required 20+ votes in time before it was closed. I was prepared to open another feature request, but the directions when opening a new feature request state
<!-- Please search existing issues to avoid creating duplicates. -->
so I'm uncertain of the protocol. Does this only mean active tickets?
The closed feature request garnered 9 votes, so there was some interest.
The up/down cursor prompt only works per session and hence, only if you have already done a search. I too use a regular expression routinely from session to session, so I have to open up a notepad file that has my patterns then copy them to the search/replace window. Royal pain.
And I agree, there should be a drop-down.
Use the up and down arrows. There is placeholder text to mention this - see the gif - but it is easy to miss. Not as nice as a dropdown though as you have to cycle through recent entiries.

Visual Studio Code search across files (find in files) is not working

I am using Visual Studio Code 1.31.1 in MacOS 10.13.6. I open VSCode, I open a folder of text files, and I press command-option-F, or use Edit -> Find in Files. I search for a string that I know for sure exists in multiple text files in the open folder, and it says it can't find it.
Searching across files works if I have the folder open and have each and every single file open as a tab, which is rather pointless. Is there a way to search across files without actually having them all open as tabs?
I think it was because I opened a folder on Google Drive File Stream. It works fine on local files.
In my case, this was caused by me accidentally toggling the "Search only in Open Editors" option.
Had this same issue, the search functionality was only working for files that were open in the editor. My issue was that VS Code had an update downloaded and ready to update, so I just restarted VS Code, let the update finish and the issue was gone.
It could be that the search is looking into all folders (including node_modules ones), so as it is too big, the search never ends
To fix that, you can list all folders that you want to exclude of the search, to do that, open your vscode settings (ctrl + ,) type "Search: Exclude" in the search box and add your folders. (Btw some are already added by default)
Besides, remember to enable that filter in your search, this is simple, just toggle on the gear button in your search section
If you are still not sure about what to do, take a look in this briefly gif
Had the same issue on Mac, seems like it was related to Google Drive. once I moved the files on my local drive the search worked fine.
Check out your vs code settings. It excludes some folders by default e.g. node modules.
Go to settings, search "Search" , there will be list to exclude folders.
Remove item which might be accidentally got included, which might causing search item in all directory is not working.
I had this problem today. Turns out I had a deprecated setting for advanced RegEx searches "search.usePCRE2": true, Once removed, search started working as expected.
I just had this problem on VS Code 1.58.2 / Mac OS 10.15.7
None of the above solutions worked for me, it still keeps saying 'No results found in open editors' no matter what I do.
But I did get it working by changing the 'Search: Mode' in the settings (for the workspace, or any other scope if needed) from 'view' to 'reuseEditor'.
Yes, this doesn't fix it if you really want the results in the Explorer tab rather than a completely new editor window, but it works.
I had the same issue, i fixed mine by removing files in .gitignore
I had an issue with searching in a project with git submodules and found that the gitlens add-on defaults to ignore searching any submodules:
Setting this to 2 or more may address your problem.
In my case, I had somehow gotten my Explorer set on a subfolder of my project. Closing VS Code and reopening the workspace reset everything and search worked again.
In my case, it was files with no extensions I was not able to find. Once I added those files an extension, I was able to find them via the search feature.
I initially wrote this answer describing a confusing "inverted" behavior of the Search only in Open Editors option/button.
However, after playing around it turns out that what the GUI was showing was not "in sync" with what the search results were returning. Toggling the options a few times appears to have fixed things.
So if your search doesn't appear to be returning any results, I would suggest toggling the Search only in Open Editors and Use Exclude Settings and Ignored Files options.
Otherwise, for information, here is my previous answer:
VS Code has an extremely confusing "inverted" interface when it comes to the option Search only in Open Editors.
There is also another option which affects how search works in a confusing way: Use Exclude Settings and Ignored Files.
The below screenshot shows both:
Note that:
Search only in Open Editors is OFF
Use Exclude Settings and Ignored Files is ON
With these options I get search results back, with them set the other way around - confusingly - I get nothing.
Important to note:
If you turn Use Exclude Settings and Ignored Files OFF, then VS Code seems to stop searching any files, EXCEPT for those which are currently open in tabs. This is very confusing and not the behavior one would expect. The expected behavior would probably be to search the whole opened Folder/Workspace by default.
If you turn Search only in Open Editors OFF, then only open editors will be searched. This is the "inverted" behavior. My current build of VS Code has the indicator "inverted" for this GUI element. When it looks like it is in the "ON" state, it is actually "OFF". When it looks like it is in the "OFF" state, it is actually "ON'.
These two things interact in unexpected ways: (This is the behaviour I observed after toggling both buttons a few times. It is different to what I was seeing a few minutes ago.)
Open Editors (looks like) it is OFF, Use Exclude Settings (looks like) it is ON, search appears to search whole workspace.
Open Editors (looks like) it is OFF, Use Exclude Settings (looks like) it is OFF, search appears to search open tabs only.
Open Editors (looks like) it is ON, Use Exclude Settings (looks like) it is OFF, search appears to search whole workspace.
Open Editors (looks like) it is ON, Use Exclude Settings (looks like) it is ON, search appears to search whole workspace.
I suspect that when typing / editing the search terms, replace option, and files to include/exclude options, VS Code does not check the state of the option buttons before performing the search. This is likely the source of the bug I was seeing earlier.

Fuzzy file opening in vscode

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.

VSCode Filter Problems tab for currently opened file only

I'm looking for a linter feature like-atom that shows the problems by either line, file or project.
Is it possible to filter the Problems tab to only show the errors and warnings in the file being visualized or in the files opened in different tabs instead of from the entire project?
VSCode v.1.23 added the ability to filter the Problems panel by files, see problems view filtering in the release notes.
So you can include (or exclude via the usual glob negation !) only a certain file by entering its name (you may need only a part of it). The filtering is done only within opened tabs however. So you cannot get the entire workspace's problems listed when only some of its files are opened.
The ability to filter the problems panel by the current file has been added to the Insider's Build just recently (#mid-November 2019) so should be in the November 2019 update.. See https://github.com/microsoft/vscode/issues/30038 and https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_41.md#problems-panel
More predefined filters are added to the Problems panel. You can now
filter problems by type and also see problems scoped to the current
active file.
The feature you describe is not currently in VSCode, (I miss it too having got used to it in Eclipse)
There is an open issue with VSCode for this:
Show problems only for currently active file / active line #30038

Eclipse content assist (for PHP or anything) not using active working set

The Eclipse content assist for PHP (and I'm assuming for other types as well) isn't using the currently active working set - it's searching ALL files in the project. How do I change it to only use the active working set?
When doing a Ctrl+Shift+R search, it was also looking for all files in the project (not what I wanted), until I clicked the small black triangle in that window and selected the working set I wanted it to use. Now it successfully only shows the files that match my search string in the working set. However, this doesn't change anything in the autocomplete content assist feature (i.e. doing a Ctrl+Space to complete the name of a function or variable). Is there any way to accomplish this?
I'm using Eclipse Indigo release, so it's very recent.
I'm afraid it's not possible the way you put it. Eclipse Working Sets just give you a way to organize your projects.
However you may want to take a look at Mylyn, which is fully integrated with Eclipse platform. Here and here is a nice overview of what you can do with Mylyn. But briefly, what it allows you to do is to create a task and maintain a context associated with it. This way, only the relevant files will be displayed in Project Explorer and autocomplete would suggest you only task-focused options.