Using Visual Studio Code how can I jump to the next found item from the active editor? - visual-studio-code

If I search something in Visual Studio Code with Ctrl+Shift+F, the result appears in the SEARCH pane.
If I click or push Enter on an item, it will be opened in the editor window.
How can I jump to the next found item if the editor window is active, without using the mouse?

F4 and Shift-F4 will traverse your search results even if an editor window has focus.
If the search pane has focus the arrow keys will tab down to each found entry below the search widget and the file and location will be opened and highlighted as you go up and down. If the folder is closed, the right arrow will open it. And the left arrow will close it again. It is pretty slick actually.
And Ctrl+Shift+F gives focus back to the search pane and you can scroll through your old results (with the arrow keys or F4) even if another term was selected and populates the search input - as long as you don't hit enter - which would perform the new search.

Related

save search on visual studio code

I am having a trouble with VS code. I would like to save the search results so I can get back to it again. specially since there is a lot of results and I do delete/filter them manually by clicking on x dismiss button.
I used the Open in editor, which open new tab with all results however it's not useful since I can browse the results quickly or reopen it again in the search pane.
Regards,
From I believe version 1.41 of VSCode you have a separate search editor which I guess will do what you're looking for.
Just open you command palette and search for "Open search editor". You will be presented with a couple options (open and open to the side).
When you have some search results which you want to save, you can click on the "Open in Editor" link shown next to the results summary.
This will open a text file with the similar search bar on top, and your current search results will be loaded in a text file format. You can press Ctrl-S or use File > Save to save it in a .code-search file.
You can close and re-open this file any time to view the results. You can click "Search Again" to refresh the results (note, this will lose any customization and bring back dismissed results). You can use Ctrl-click to jump to files or lines mentioned in the search results.
Unfortunately you cannot reload this back into the search pane (AFAIK). However, since Editor pane can be split, you can split this file's editor to a separate pane on the side, and close the Search pane.

See unsaved changes in vscode

Sometimes when closing vscode, or a tab therein, I get a dialogue asking "Do you want to save the changes you made to filename?" However, the unsaved edits are actually from a previous session that was closed without such a query, probably when turning off the computer, so I can't remember if it was meaningful edits, or maybe just an accidental key-press, like a shortcut gone wrong; and doing undo to revisit the last edits doesn't work either.
My question: How can I see the diff between the saved version of a file, and the version in the editor window? I think it would be nicest just to have a "show diff" option in the dialogue, but for now I'm also happy with a command line diff command.
I'm using ubuntu 20.04.
I'm using VSCode version 1.52.1 on MacOS and I had a similar problem that may not be the same problem, but I'm guessing it will work for you as well.
When you're in the Explorer view, in the upper left part of Explorer you have your "Open Editors." If that shows a dot to the left indicating that the buffer has changes in it, you can right click the file name and select "Compare with Saved." This will open another buffer to the side that will show you any unsaved changes.
To get rid of that window (it took me a bit to figure this out I'm sorry to say!), you can click the 'X' to the left of the extra buffer in "Open Editors."
Hope this works for you!
A few bright notes for the keyboard players out there:
The command you are asking about has a default shortcut. Unless you've applied a keyboard map extension, the Ctrl+Kd arpeggio opens the very same diff view between the active and saved versions of the current file. The default shortcut to close an editor tab (be it the diff or a file or anything at all) is Ctrl+W.
The command, like any command in VSCode, is also accessible via the Ctrl+Shift+P command dropdown (on Linux, F1 opens it too). Start typing e.g. compa sav (it saves your keyboard wear and tear to shorten words to a prefix which is unambiguous enough), and the list will shrink dynamically to just a few commands. Yours is File: Compare Active File with Saved. When it's close to the top enough, navigate the list of commands with the down arrow and execute it with Enter. As a bonus, you may click on the little gear to the right of the command currently highlighted in the list and redefine its shortcut, if you use it very often and prefer a chord shortcut to the default arpeggio one. Sorry, there does not seem to be a shortcut in lieu of the gear click. If there is, please let me know!
But if you really, really want to right-click on the filename in the Open Editors view of the Explorer sidebar, you can open that view directly with, you guessed it, a shortcut: Ctrl+Ke. And if you change your mind on a dime right at this moment, or realize that you in fact never had a mouse to do the right-click in the first place, use Shift+F10 to drop down the "right-click menu", properly called the context menu, which you navigate with arrows and execute with Enter (that's kinda a common theme, as you probably noticed). This works mostly anywhere the right-click does.
While in the Open Editors view, to switch to an editor file tab, move the selection to the desired file. Press Space to bring the file into view but stay in the Open Editors view, or Enter to bring the file into view and shift the keyboard focus to it. Pressing Ctrl+Shift+E brings focus back to the editor from any view in the Explorer sidebar. The same shortcut moves focus to the Explorer sidebar from the editor.
Happy ♬ k'boarding ♬!
ctrl+shift+P (or command+shift+P on mac) and fuzzy search for "compare changes with saved files"

VSCode: Disable mouse+ctrl interaction

I often double-click to select followed by ctrl+c to copy. I am finding in vscode that ctrl press with the mouse over a word can perform an action. In some cases it selects the whole line, and in others it jumps to the definition of what is underneath. Is there a way to turn this off?
Note that if you move the mouse cursor off the word then it appears the action is not performed.
You could click on Visual Studio code->Preferences->KeyBoard Shortcuts. Keyboard Shortcuts page opens up. You could change any of the keyboard short cuts, by click on edit icon on the left as shown below
You can change the behavior of these features or disable them altogether by going to Tools > Options > Text Editor.
https://devblogs.microsoft.com/cppblog/productivity-structure-visualizer-ctrl-click-to-go-to-definition/

How to close the search toggle for vscode?

This is an extremely stupid question... but how do I close/toggle the search box in vscode?
I hit [ cmd + shift + f ] to do a global search, but then I need to reach for my mouse to actually close the box to allow for more screen space.
I've searched through their issues, and there seems to be another user in the past who also experienced something similar --> https://github.com/Microsoft/vscode/issues/32613 , but the solution provided of cmd - b only works for closing the sidebar.
My developer speed has drastically dropped since this issue, and I'm certain there's been a fix.
Please help. :(
**added in picture here -->
Press CTRL + SHIFT + E. It will switch to and focus the explorer.
Your search results are appearing in the panel, not the sidebar.
To toggle the panel:
pc/mac: ctrl + ` (backtick)
mac: ⌘ + J
However, if you want your search results to appear in the sidebar (which I think is the default behavior), then add this line to your settings:
"search.location": "sidebar"
Similar to what Vijey has mentioned, you can use the Toggle Panel keyboard shortcut which will do the job for me. On A mac the shortcut is
⌘ Command+J
I'm coming from sublime where the search results appear in a new tab - making it much easier to close the results (just like closing an other tab)
The best way to get rid of the search panel is by doing the following: -
On a windows computer, press and hold CTRL + Q
A window will then pop up, you can then release Q when the window pops up but you still have to hold down the CTRL key to keep the pop up open
3.Now use your mouse to click on the option called explorer and the search menu is now gone
There is no keyboard shortcut to close the search panel. However, you can create a shortcut yourself as shown in the attached image.
1) Go to File > Preferences > Keyboard Shortcuts.
2) Search for the command 'Close Panel' and set it to your convenient keyboard shortcut.
In the image below, I set it to Ctrl+F8.
If the search box displays in the sidebar (see Amr Noman's answer on how to set that up if it isn't already), How do you close the search box and go back to your project folders? In this case, there is no tab you can close with a click of the mouse. One way is to set up a keymap shortcut, e.g.
{
"key": "cmd+'",
"command": "workbench.files.action.showActiveFileInExplorer"
},
You can figure this out by going to Preferences -> Keyboard Shortcuts and searching for sidebar. One of the hits is described as "File: Reveal Active File in Side Bar"
More generally, any action that hides your project folder view in the sidebar can be cancelled by this shortcut.

remove search highlighting via keyboard shortcut in Eclipse

After doing a Java or File search in Eclipse, the (purple) highlighting of matches in files persists indefinitely, distracting me from whatever task I try to accomplish after I complete my search.
I know that I can open the Search view (by pressing Alt+Shift+Q,S, or by clicking its icon) and then click the "Remove All Matches" button that looks like an advertisement for Dos Equis, but I get tired of all this view-activating and clicking.
I want to clear search results in Eclipse using just the keyboard. Is there a way to do this?
Press Ctrl+F7. Keep on Pressing F7 when reach search view. Release Ctrl Key.
Close search view(in fact any view) as explained here
Once search view is removed from the current perspective search highlight will be removed automatically. If you want to see it again then open search view.