Eclipse jump to closing brace - eclipse

What is the keyboard short cut in Eclipse to jump to the closing brace of a scope?

Place the cursor next to an opening or closing brace and punch Ctrl + Shift + P to find the matching brace. If Eclipse can't find one you'll get a "No matching bracket found" message.
edit: as mentioned by Romaintaz below, you can also get Eclipse to auto-select all of the code between two curly braces simply by double-clicking to the immediate right of a opening brace.

As the shortcut Ctrl + Shift + P has been cited, I just wanted to add a really interesting feature: just double-click to the immediate right of the {, and Eclipse will select the whole code block between the opening { and corresponding closing }. Similarly, double-click to the immediate left of the closing '}' and eclipse will select the block.

With Ctrl + Shift + L you can open the "key assist", where you can find all the shortcuts.

On the Macintosh, place the cursor after either the opening or closing curly brace } and use the keys: Shift + Command + P.

To select content use Alt + Shift + Up arrow
To select content up to the next wrapping block press this shortcut again
To go back one step press Alt + Shift + Down arrow. This is also a useful shortcut when you need to select content in a complex expression and do not want to miss something.

Press Ctrl + Shift + P.
Before Eclipse Juno you need to place the cursor just beyond an opening or closing brace.
In Juno cursor can be anywhere in the code block.

I found that if the chosen perspective doesn't match the type of the current file, then "go to matching brace" doesn't work. However, changing perspectives makes it work again. So, for example, when I have a PHP file open, but, say, the Java perspective active, pressing Ctrl + Shift + P does nothing. For the same file with the PHP perspective active, pressing Ctrl + Shift + P does exactly what you'd expect and puts my cursor beside the closing brace relative to the one it started at.

Related

VS Code: bring up the Ctrl+Shift+P Command Pallette but without ">" in it

When you press Ctrl + Shift + P (or whatever you bind it to) in VS Code a Command Palette pops up. It brings up a magical textbox with a angle bracket > string in it that you can type in to access commands, like >fold all.
But most of the time I instead use this magical textbox to search for functions or objects in my code via #function or in all dependencies via #function, or just open files myfile.py.
So every time I press Ctrl + Shift + P I immediately have to follow it up with a backspace to remove angle bracket >, so that the string in the magical textbox starts with the appropriate # or # character instad of >.
Sadly, typing >#function does not search for function, so the angle bracket > has to be removed manually.
How do I get VS Code to bring up the magical textbox but not insert the angle character >?
(Note: I know I could just write an AHK or similar macro to follow up Ctrl + Shift + P with a backspace, but I don't trust backspaces in a macro.)
Alternately, how do I access a search box with similar #function search behaviour? (The answer is definitely not Ctrl + F.)
You can look the shortcuts just type Keyboard Shortcuts in the command pallet (or magic textbox :D) and search for "Go to File", default it is CTRL+P

Selecting block of code in Visual Studio Code

Is there a keyboard shortcut or an extension that would allow me to select a block of code?
I'd like to select everything between curly braces, between HTML tags, etc.
Use Alt + Shift + → to expand the selection between braces or tags.
Use Alt + Shift + ← to shrink the selection between braces or tags.
Here is the Microsoft Visual C++ shortcuts cheatsheet that might help you.
Update 2019/3: this inner functionality of Visual Studio is not working very well after some updates. Alt + Shift + → now selects things including braces (which annoys me).
It is not like its behavior before. It selected things between curly braces, when I first posted this answer. I'm using Mark's answer now.
If anyone has a better solution (without an extension) now, please leave a comment.
On Mac Ctrl + Shift + → to expand the selection. Press multiple times to expand to the block.
Try the expand-region extension. It currently works for JavaScript and HTML. To select ever-increasing or decreasing scope.
A quicker way is selecting a line then expanding the selection like this:
Select line Ctrl + L
Expand selection Alt + Shift + →
Doing this inside a block (HTML element, JavaScript curly braces) will select the inner block (HTML element content, inside curly braces). Do step 2 again to select block including the container (HTML element, whole function, class, etc.)
In Visual Studio Code, there is a new option called Balance. First you can place the cursor in a suitable block. After that, you can press Ctrl + Shift + P. Type balance and it lists like below.
Now press Enter, it will select the related code block like below.
For simple use, you can add a shortcut key binding.
A real working solution:
Press Command + P and search for Select to Bracket
To bind it to a key, press the little Settings icon on the right. The "Keyboard Shortcuts" Window will appear as shown in the image. Double-click on Select to Bracket and press a Keyboard shortcut you like, for example Command + Shift + H.
Now, whenever you want to select code in a block, put your cursor inside the block and press your shortcut.
It is like magic.
⌃⇧⌘← or ⌃⇧⌘→is also useful for this purpose.
A real working solution:
Search for Select to Bracket and bind it to whatever keys you like.
It is like magic.
If you are using Java in Visual Studio Code and you don't want your block selection to include the brackets (or any other peripheral character) then do the following:
Go to Visual Studio Code settings by pressing Ctrl + ,.
Search for "Java selection range" and deselect it.

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.

VS code, jump to after closing quote/braces/parenthesis

With Visual studio Code if I'm in the middle some quote/braces/brackets/parenthesis is there a way to jump to after end of the current block?
Eg.
If
it allows me jump to the end of the quote
Or from:
to
April 2020 Update
Yes, use Ctrl+Shift+\, (or ⇧ + ⌘ + \ on Mac) to jump to closest bracket. If cursor is currently in-between the brackets, first it will jump to closing bracket, each consequent press will jump between opening and closing brackets.
You can reassign the binding to your liking in Keyboard Shortcuts using editor.action.jumpToBracket command.
Use ctrl+right it triggers the cursorWordEndRight command.
It moves the cursor by whole words. These "words" include spaces, parenthesis, commas and the likes.
You can modify the keybinding shortcut to what you desire.
I personally use ctrl+alt+space for now.
It's not perfect but it's the best alternative I have currently.
The TabOut extension doesn't do exactly what you're describing (I think), but comes very close.
Note: I'm still trying it out so I'm not sure if I like Tab meaning different things depending on the context, but so far it's getting me pretty close to what I want.
use Ctrl + Enter in Windows 10 if you want get outside and go downline. or Ctrl + Shift + Enter if you want get outside and go upline.
Finally find out on Mac to jump to closing bracket/parenthese :
⌘ + ⇧ + £

How to search string under cursor in Eclipse

In vim, pressing * in command mode performs an automatic search of the word under the cursor. How can I obtain the same in Eclipse?
A combination of two keystrokes:
First, hit Ctrl + Shift + Right Arrow to invoke "Select Enclosing Element". This will select the word under your cursor.
Use Ctrl + K (Cmd + K on OS X) to "find next".
It appears it was not possible in 2004, and it's still not possible, apparently. I'm speechless...
I also need this functionality and created a small plug-in which adds commands for doing this. You can download it and find more details here: http://eclipselabs.org/p/eclipse-tweaks/
Windows 10, tested on Eclipse 2020-03:
Two Steps:
1. Alt + Shift + Up Arrow, to select the word under the cursor
2. Ctrl + K to find the selected word forward
(Ctrl + Shift + K to find the selected word backward)
NOTE:
If you are inside an XML tag, Alt + Shift + Up Arrow will select from the beginning of the tag to the end tag, including all enclosing elements. Try it!
BONUS:
Ctrl + Shift + Down/Up arrows to navigate methods, as sometimes the selected word is a method you want to go to.
Better still,
Ctrl + O - Go to a specific method, by searching (Just enter the first few letters of the method, and Enter)
Cheers
Press Ctrl + k on a Windows machine. On a Mac, Cmd + k should work (seen here).
Not exactly the same, but maybe helpfull if you work with java. In a .java file you can press
CTRL + SHIFT + u
to find occurences in the same source file.
You can also use Shift + Ctrl + K to search next backwards.