how to find 'Find All refernces' in current file only with visual studio code? - visual-studio-code

when i hit Find All References it try to find all reference in files inside workspace.
i want to use current file only when search 'Find all reference' function in vs code.
i want to search only References in yellow marked file which is currently editing file and don't want to search files all other files like purple X marked area.

Open the find feature with Ctrl + f (or Cmd + f on mac)
Enter the search term and configure your desired case sensitivity/regex usage
Press Ctrl + Shift + L (or Cmd + Shift + L on mac)
All occurrences in the open file will be selected. Press Esc to return focus to the editor.

You can also select the text you'd like to find and press ctrl + d to jump to each reference of that text in the file!

ctrl + shift + f will open search.
Click on the 3 dots (Toggle search details) under search dialog box. [ ... ]
Under file to include, specify the path of the file under which you want to find all the references to the key you're searching.

Related

Is it possible to save the search results of Find in Files in Visual Studio Code? [duplicate]

Does Visual Studio Code have any way to copy the results of a search into a new window?
As a bonus, I'd really like to be able to drop the file name and just copy the lines containing the text of my search results to a new window.
For example, I'd like to to be able to copy the results of the search below to a new editor window. I don't mind if I need to install an extension to do it.
The following works for a single file:
CTRL + F
Type your search string
CTRL + SHIFT + L to select all occurrences found (max. 999)
ESC (or close search dialog with top-right X)
CTRL + I to select whole lines
CTRL + C
Open new file
CTRL + V
VSCode 1.23 added the ability to copy your search results, see release notes: copy search results.
The search results tree context menu includes three new options: Copy,
Copy Path, and Copy All. This was a highly πŸ‘'d request which will
make it easier to share or export your search results.
The results are not very pretty or clickable when copied/pasted, so be forewarned. There is an issue tracking the "copy search results" format (see https://github.com/microsoft/vscode/issues/68877) and it is on the 2019 Roadmap (see https://github.com/Microsoft/vscode/wiki/Roadmap#workbench) so hopefully it will be improved.
Update as of v1.41 you can move your search results to a new editor and easily select all and copy there. After searching (which can work across multiple files); click the "Open in Editor" link, as shown in this demo:
Another advantage of the search editor is that you can get "context" around your search result. So you can get some number of lines before and after the whole line with your search term in it. And, of course, line numbers will be copied too.
And you can just save Ctrl+S the search results editor itself! And cut lines from there. Or add notes. With syntax highlighting. It will ask where you want to save it, defaulting to the folder where you initiated the search. It will be named like yourFolder\yourSearchTerm.code-search.
For more info on the new search editor, see https://code.visualstudio.com/updates/v1_43#_search-editors and
Select all occurrences of current selection
CTRL+SHIFT+L
https://code.visualstudio.com/shortcuts/keyboard-shortcuts-windows.pdf
As of 12/2020 CTRL + SHIFT + L doesn't work (for me)
After search results are rendered, right-click onto the text file and select "Change all occurrences"(or CTRL+F2). This will automatically select the the matched text items. Then you can simply copy it.
This will work for a single file, assuming each line you care about begins with the search text:
1. Highlight your search string
2. CTRL + SHIFT + L to select all occurrences found
3. SHIFT + ↓ to select all of those lines
4. CTRL + C
5. Open a new file
6. CTRL + V
There's now an "Open in editor" button under search inputs
Wrong. Per the document the correct format is to use Right Alt + Enter, the use Ctrl + C and then open a new tab and paste your results with Ctrl + V

Open already opened file in a different editor group in Visual Studio Code

What I am looking for is a way to do the following in Visual Studio Code:
Go to Definition on a symbol (which often opens a new file in the same editor group)
Open this newly opened file in a editor group next to current
... and switch back to the original file
Is there a command / key binding that would let me do 2nd bullet item?
Short Answer
Ctrl + Alt + β†’ does that on Windows.
Details
This is my normal flow:
F12 to go to a symbol definition.
Ctrl + Alt + β†’ to open the file on the right.
On Linux or iOS
Find the equivalent shortcut by opening File > Preferences > Keyboard Shortcuts (or running Open Keyboard Shortcuts in the command palette), and searching for these two commands:
workbench.action.moveEditorToNextGroup
workbench.action.moveEditorToPreviousGroup
If you are here, like me, looking for a way to open files in the next group, by Ctrl + Click.
Then adding Alt to the combination may do the trick. My VSCode version is 1.60.
!IMPORTANT: The new tab opened via Ctrl + Alt + Click, will always be to the right of the current. So, if you have already opened two groups, then move the tab to the left to have new tabs at the right, otherwise it will create third group.
in mac os you can use this key binding cmd + \
in windows you can use this key binding CTRL + \
I'm pretty sure what you're looking for is a combination of the answers above. I find this works:
Ctrl + \ View: Split Editor
Ctrl + Alt + β†’ View: Move Editor into Next Group
Equivalently
(no default keybinding) View: Split Editor into Right Group
Caveat: if the file is already open in the other editor group, then it will be opened (not "cloned"). There may be a configuration setting to alter this behavior, but I couldn't find one quickly.
The result looks as follows. Suppose you are in some file on the left, and there is another editor group on the right (e.g. after executing Ctrl + \). After running the two commands above, then the currently open file will still be open on the left, but will also be open in the editor group on the right.
Tip: if you don't feel like assigning a keybinding, but would like to access the command (relatively) quickly, just type
Ctrl + Shift + P srg

Visual studio code - how to copy search results?

Does Visual Studio Code have any way to copy the results of a search into a new window?
As a bonus, I'd really like to be able to drop the file name and just copy the lines containing the text of my search results to a new window.
For example, I'd like to to be able to copy the results of the search below to a new editor window. I don't mind if I need to install an extension to do it.
The following works for a single file:
CTRL + F
Type your search string
CTRL + SHIFT + L to select all occurrences found (max. 999)
ESC (or close search dialog with top-right X)
CTRL + I to select whole lines
CTRL + C
Open new file
CTRL + V
VSCode 1.23 added the ability to copy your search results, see release notes: copy search results.
The search results tree context menu includes three new options: Copy,
Copy Path, and Copy All. This was a highly πŸ‘'d request which will
make it easier to share or export your search results.
The results are not very pretty or clickable when copied/pasted, so be forewarned. There is an issue tracking the "copy search results" format (see https://github.com/microsoft/vscode/issues/68877) and it is on the 2019 Roadmap (see https://github.com/Microsoft/vscode/wiki/Roadmap#workbench) so hopefully it will be improved.
Update as of v1.41 you can move your search results to a new editor and easily select all and copy there. After searching (which can work across multiple files); click the "Open in Editor" link, as shown in this demo:
Another advantage of the search editor is that you can get "context" around your search result. So you can get some number of lines before and after the whole line with your search term in it. And, of course, line numbers will be copied too.
And you can just save Ctrl+S the search results editor itself! And cut lines from there. Or add notes. With syntax highlighting. It will ask where you want to save it, defaulting to the folder where you initiated the search. It will be named like yourFolder\yourSearchTerm.code-search.
For more info on the new search editor, see https://code.visualstudio.com/updates/v1_43#_search-editors and
Select all occurrences of current selection
CTRL+SHIFT+L
https://code.visualstudio.com/shortcuts/keyboard-shortcuts-windows.pdf
As of 12/2020 CTRL + SHIFT + L doesn't work (for me)
After search results are rendered, right-click onto the text file and select "Change all occurrences"(or CTRL+F2). This will automatically select the the matched text items. Then you can simply copy it.
This will work for a single file, assuming each line you care about begins with the search text:
1. Highlight your search string
2. CTRL + SHIFT + L to select all occurrences found
3. SHIFT + ↓ to select all of those lines
4. CTRL + C
5. Open a new file
6. CTRL + V
There's now an "Open in editor" button under search inputs
Wrong. Per the document the correct format is to use Right Alt + Enter, the use Ctrl + C and then open a new tab and paste your results with Ctrl + V

How to select current word in Visual Studio Code (VS Code)?

How to select the current word, that is where the caret is at.
Note: I am looking for the shortcut for Visual Studio Code(VS Code), the text editor, and not Visual Studio IDE.
On Mac OS: Cmd+D
On Windows & Linux: Ctrl+D
Above solved the purpose for me.
But ⌘D is defined as "editor.action.addSelectionToNextFindMatch", so if you press it more than once, it will try to search and select same word in the file which then can be used to do "multi word editing".
You are looking for Shrink/Expand Selection.
Trigger it with Shift+ Alt+Left and Shift + Alt+Right
Update:
This is now called Smart select API.
This feature uses semantic knowledge to intelligently expand selections for expressions, types, statements, classes, and imports.
It is Ctrl + D that works for me in latest Visual Studio Code on Windows.
Go to File -> Preferences -> Keyboard shortcuts, you will find this:
If you want to ctrl+w to behave the same as in Idea just go keyboard settings
Search for Expand selection. Set new shortcut cmd+w or ctrl+w depending on your OS.
Also re-bind other commands that use ctrl+w to use another shortcut that you want, for example cmd+f4
You can edit keybindings.json to avoid using UI.
Shift + Alt+Right Arrow if the word is in camelCase then you will have to click Right Arrow again to select the whole camelCase. Every time you press Right Arrow again while still holding Shift + Alt down you will select a further part of the code.
so:
first the word.
then if it's part of a camelCase then the camelCase.
then if it is in a string the whole string.
... (many other posibilities)
the whole line.
everything inside the parentheses code block
the whole file
at any given time you can go back to the last selection by clicking Left Arrow instead of Right Arrow
I don't know about CTRL + w in the old Visual Studio Code but in the JetBrains IDE's this is the equivalent to CTRL + w by holding down CTRL and clicking w to select more and holding down CTRL + Shift and clicking w to unselect.
Another possibility which helps to avoid selecting only one word in camelCase is CTRL + d this will just select the whole camelCase. This will however have the side-effect of also changing the current "find" criteria.
thanks Chandan Nayak for this extra shortcut.
An unpopular opinion: you can now have Resharper keybindings, if you come from Jetbrain's camp.
The Ctrl+W expansion grow and shrinks is different from expansion selection.
On "File/Preferences/Keyboard Shortcuts" I deleted the shortcut "Ctrl + W" to close the current tab action, because for this "Ctrl+F4" works for me.
Update (14 days later): Yesterday I installed VSCode 1.34.0 - I think since then the functionality is "Ctrl + D". I was very suprised.
For any editor, you can use the below shortcuts. These shortcuts work for every text area also.
Ctrl + Shift + LeftArrow/RightArrow - this will select text word by word
Shift + UpArrow/DownArrow - this will select text line by line
Ctrl + BackSpace - this will delete text word by word
Additional
in intellijIdea
Ctrl + w - use for the select current word, after giving second Ctrl + W it will select the second word also. Like that you can select the whole line.
Ctrl + d - you can duplicate current line.

Eclipse - List of default keyboard shortcuts

Is there a list of the default Eclipse keyboard shortcuts? I'm generally looking for language agnostic things like starting the debugger or deleting an entire line in the source editor.
Rather than a full list of shortcut (JGlass mentions for Eclipse 4.6 this pdf), I prefer using only a few shortcuts:
CTRL+Shift+L: "Show Key Assist", List of shortcuts (depending on the context)
CTRL+3: Quick Access
Source: "Good features of Eclipse 3.6 (Eclipse Helios) JDT, 2011, from Sony Thomas"
Those two covers almost everything.
You can add two others:
CTRL+1: Quick Fix
ALT+Shift+F1: Plug-in Spy
Note that Eclipse 2019-09 now shows key bindings when command is invoked.
For presentations, screen casts and learning purposes, it is very helpful to show the corresponding key binding when a command is invoked.
When the command is invoked (via a key binding or menu interaction) the key binding, the command's name and description are shown on the screen.
Key binding of triggered command shown on screen
You can activate this in the Preferences dialog via the Show key binding when command is invoked check box on the General > Keys preference page.
To toggle this setting quickly the command 'Toggle Whether to Show Key Binding' can be used (e.g. via the quick access).
As VonC said you can get alist of short cuts with the following command.
Ctrl + Shift + L "Show Key Assist", List of shortcuts (depending on the context)
SHORTCUTS FOR DEVELOPMENT
But here are some which you will use often during your development.
Ctrl + Shift + P Switch between openning and closing braces.
Ctrl + Shift + R Open any file quickly without browsing for it in the Package Explorer. This shortcut opens a dialog box that accepts the name of the file you’re looking for.
Ctrl + Shift + T Open a type (e.g.: a class, an interface) without clicking through interminable list of packages. If what you want is a Java type, this shortcut will do the trick.
Ctrl + O Go directly to a member (method, variable) of a class file, especially when there are a lot of methods.
Ctrl + Shift + F Format code.
Ctrl + Shift + / Comment out XML or JSP code.
Ctrl + L Go to line number N in the source file.
Ctrl + E Show a list of open editors.
Ctrl + F6 Move between open editors.
Ctrl + 1 Quick Fix.
Ctrl + 3 Quick Access.
Ctrl + Q Go to the last edit location.
Ctrl + T Go to a supertype/subtype.
Ctrl + I Indent selected code block.
Ctrl + + Move to one problem (i.e.: error, warning) to the next (or previous) in a file.
F3 Go to a type declaration.Alternatively, you can hold Ctrl down and click (ie: Ctrl + Click) the hyperlinked variable.
SHORTCUTS FOR VARIABLE GENERATION
Ctrl + 2 + L Generate return value type and variable assignment
Alt + Shift + L Generate return value type and variable assignment. but here you can make selections.
SHORTCUTS FOR DEBUGGING
F8 Resume
CTRL + F8 Resume.
F5 Step Into
F6 Step Over
F7 Step Return
CTRL R Run to Line.
F11 R Debug
CTRL + SHIFT + B Toogle Break Point
You can find further shortcuts under :
Help β†’ Help Contents β†’ Java Development User Guide β†’ Reference β†’ Menus and Actions
Previous answer not quite correct as in Eclipse you can redefine keyword shortcuts (as I often do).
You can always access current list of defined shortcuts by pressing Ctrl + Shift + L in Eclipse (on Windows at least).
The full list of defaults in Eclipse 4.6 and earlier versions can be obtained from this GIT Hub page:
https://github.com/pellaton/eclipse-cheatsheet specifically https://github.com/pellaton/eclipse-cheatsheet/raw/master/eclipse4.6/eclipse-shortcuts-4.6.0.pdf