How do I select text inside of braces in Visual Studio Code? - visual-studio-code

In Atom I can select inside of brackets with CMD+CTRL+M. How can I do this in Visual Studio Code? I've checked the keyboard bindings, but didn't find anything.

There are 2 even better alternative commands in the keybinding file you might want to check out:
editor.action.smartSelect.grow
and
editor.action.smartSelect.shrink
They select everything in between the next boundary (quotes, brackets, curly braces...) and the selection grows to the next boundary when you hit the shortcut again.
Default shortcut is ctrl+shift+cmd+right / ctrl+shift+cmd+left, which is a bit too "finger heavy" for my taste, so you might want to rebind it (I use ctrl+up / ctrl+down).

Shift+Alt+Right for selecting all text inside the braces.
CTRL+Shift+\ for jumping between opening/closing braces (or) parentheses.

Related

How to highlight multiple words on VIM and modify them all? Like CTRL+D does on VS-Code?

On VSCode, if you highlight a text, you can do "CTRL+d" and it will highlight the next matching text and add a cursor there.
You can then start typing/deleting and it will affect all the cursors.
How can I do this in VIM?
Note: I know the search and replace function, this is too slow to type, is there something as easy or almost as easy as it is on VSCode?
:%s/foo/bar
Visual explanation on VSCode:
Highlight the word you're looking to replace:
CTRL+d two times, which highlights them all:
Now modify them all at the same time:
I want this will help you.
You can do the below steps to change all selected words.
< SHIFT > + # // select the all words on your cursor.
:%s//NEW_WORD/g
If you want to change all 'const' to 'AAA',
move to one of the 'const' words and press < SHIFT >+'#'.
And type the command ":%s//AAA/g".
Move the cursor on top of a word in your code.
Type gb to add another cursor. This puts Vim into Visual
mode and ready to operate on the word you have selected.
Type gb to continue adding cursors until you’re done.
Now you can perform an action in Visual mode (delete,
change, etc).
Go back to Normal mode with <ESC>

Visual Studio Code bracket auto completion

This has been annoying me for a while. VSCode doesn't let me type a closing bracked or parenthesis or the like ( ")", "]", "}") when there is already a closing symbol of the same type.
In this WEBM you see me try to set another set of brackets and VSCode skips the closing bracket that I typed. This is extremely annoying.
WEBM
How do I disable this behaviour in VSCode? (Or correct it, so VSCode closes the inner bracket for me.)
Edit: I know I can disable auto closing brackets in VSCode with "editor.autoClosingBrackets": false. But I don't want to disable it altogether. I just want to disable the overtyping.
TL;DR: As of June 2019, it's not possible to disable only the overtyping part of the autocloseBrackets function. You can only disable auto
bracket closing altogether.
Some people suggest using the TabOut Extension for Visual Studio Code to tab out of quotes, brackets, etc.
Ok, so what I found out over at the VSC Github is this:
[...] This can be turned off via editor.autoClosingBrackets. The feature
consists of multiple parts:
one is that when ( is typed, the result is (|).
the other part that is hit here, is that when ) is typed and ) follows the cursor, ) will be overtyped.
The feature is implemented language agnostic and looks only locally at
the next character. It does not count brackets to determine if the
code is "bracket unbalanced".
(Source: https://github.com/Microsoft/vscode/issues/35799)
At the moment, it's not possible to fix this, without losing the auto
bracket closing feature. The above thread has since been closed. New one is here: https://github.com/Microsoft/vscode/issues/37315 , but no patch has come out yet.
I face the same issue,
It's because of the GIT COPILOT once I uninstall and restart the VS CODE it's working properly now

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 move out of auto-completed brackets in IntelliJ IDEA (without using the arrow keys)?

I recently switched from Eclipse to IntelliJ IDEA, and found myself wondering how to move the cursor out of a pair of auto-completed brackets.
In Eclipse after I finished typing in a pair of brackets, pressing tab brings me out of the brackets. How can I do the same thing without using the arrow keys?
Many thanks for your help!
IDEA doesn't have such feature yet. The closest equivalent is the Complete Current Statement editor action (Ctrl+Shift+Enter).
UPDATE
Initial implementation for this feature is available in 2018.2 EAP version - press Tab to jump out.
It works more like in MS Visual Studio - without visual indication of tab 'exit' position. For now, it should work in Java, SQL, Python and some other files. It will take some time for other languages to catch up - some language-specific code changes are required.
The feature is disabled by default, you can enable it in
Settings -> Editor -> General -> Smart Keys -> Jump outside closing
bracket/quote with Tab
Ctrl + Shift + Enter does not seem to work for me in IDEA 12.1.4, but I found the closest feature to what I was looking for was Shift + Enter. This completes the line, creates a new line below the current line and moves the cursor to it.
You can do this by pressing the closing symbol that you would've pressed otherwise, but was auto completed. For example, if you have just typed the f below, you would press shift and 0 (or closing parenthesis), and it will move your cursor outside of the parenthesis.
String asdf = "hello world";
System.out.println(asdf);
I went to preferences->Keymap and set a shortcut for "Move Caret to Line End" to Shift-Space. It takes me to the end of the current line I am on without adding anything, if that's what you want.
Not currently supported by Intellij. There is an open feature request on this at http://youtrack.jetbrains.com/issue/IDEA-74666. Extra votes would be nice.
Intellij supports the ctrl+shift+m shortcut that jumps to the end of the block:
https://www.jetbrains.com/help/idea/2016.2/navigating-to-braces.html
It's not quite what you're looking for, but you can type the character you are trying to move outside of (a closing paren, for example) and that should pop you outside of the auto-completed character.
Not ideal, but functional as far as I've tested it.
I set these setting:
1) I added Semicolon shortcut to Complete Current Statement:
Instead of using for loop command, I using fori command (because for command needs semicolon character):
2) I added Alt+Semicolon shortcut to Move Caret to Code Block End:
So when I inside the loop, by pressing Alt+Semicolon jumping end of the bracket, by pressing Semicolon I jumping out the bracket subsequently.
by adding these shortcuts, the speed of coding will be faster.
Such key is called "End".
You can assign any unused shortcut to "Move Caret to Line End" action in "Settings/Preferences | Keymap".
P.S. You can use Ctrl+Shift+Enter to complete your statement (in your case it will place caret at the end of line and will add ";" there) -- action called "Complete Current Statement" and shortcut can be checked/changed in a same way as described earlier.
If you decide to move back to Eclipse and use PyDev this feature by default is disabled, First Switch to PyDev Perspective and you can enable it by going under Preferences>PyDev>Editor>Typing>Enable link on Automatic parenthesis or literals closing

Netbeans Keyboard Shortcut to Jump out of Quotations

I'm using Netbeans 7 and programming PHP. I was wondering if anyone knew of a keyboard shortcut to jump out of quotations marks and parenthesis (besides the right arrow key). For example I would like to type a quotation, type some text, then:
"my cursor would be here -> |"
Then hit tab or something equivalent to jump outside of the quotations:
"some text"| <- my cursor would now be here
Is this possible to accomplish using netbeans?
Type the second (end) quote. Netbeans realizes what's going on and does exactly what you describe.
you should take the auto quotation as a help to minimaze errors:
"The user often writes a code that has opening and closing brackets, and this is very often source of compilation errors. If the IDE would insert a closing bracket each time opening bracket is typed, the likelihood of error is smaller, and the user also has a better visualization of the structure."
source: https://ui.netbeans.org/docs/hi/promoB/smartBrackets.html
I was looking to a "short cut" myself to allow me to jump outside the quotation even when the cursor is not at the end of the content, but I could not find it.
Like me, you might find this method useful as well: select the text you want to wrap in quotes/brackets and the press the opening quotes/brackets you like: NetBeans will do it for you.
source: How to surround a text in quotes in netbeans IDE
code safe ;)