1

When I do a search in VS Code, it will return the same line multiple times if the search string is found in a line multiple times. For example, if I search for "Automobile", the following line will show up twice in the search results:

var myAutomobile = 'Ford Automobile';

Is there any way to get VS Code to display the same line only once?

(I know that I can manually remove a line from the search results by clicking the 'x' on the right-hand side, but I'm wondering if there's an automated way to do this.)

Mark
  • 143,421
  • 24
  • 428
  • 436
JimP
  • 75
  • 7

1 Answers1

1

This does happen in the search panel results (and I don't think can be avoided) but if you enable this setting:

search.enableSearchEditorPreview (or search for "Search: Enable Search Editor Preview" in the settings)

and then click on the "open in editor" link at the top of the search results (after a new search after enabling the setting), a new editor tab will open with your search results and I don't see duplicates listed there.

More info: https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_42.md#search-editor and Visual Studio Code - Include context in search results

search preview

And in v1.42 (coming later this week) you can use this command search.action.openNewEditor to directly open a search editor without first executing a search in the traditional panel.

Mark
  • 143,421
  • 24
  • 428
  • 436
  • Thanks, but the search results in the new window aren't hyperlinks. I submitted a feature request to Microsoft: https://github.com/microsoft/vscode/issues/90033 – JimP Feb 04 '20 at 20:54
  • They are links if you Ctrl+click. – Mark Feb 04 '20 at 21:44
  • Too bad that the original request (https://github.com/microsoft/vscode/issues/90033 ) was closed - I had exactly the same problem and I think this "known limitation of the search viewlet" should be fixed! – MBaas Feb 20 '20 at 09:50