After VS Code auto closes a quote, parentheses, or bracket, what key do i hit to move to the next position after that closing mark? - visual-studio-code

Sorry for roughly worded question.
I'll start typing something in VS Code like class="bob", and as soon as I type the opening " mark, VS Code will auto populate the closing " mark as well. Very helpful! BUT, once I'm done entering my string of information, I find myself having to adjust my keys on my keyboard to arrow right past the character that was automatically added, then hit a space, and continue on my coding way.
However this can interrupt my typing flow, as it would be just as easy if not easier for me to type the closing " mark myself without adjusting my hand from the default keyboard position.
This happens with other characters, too, not just quotes. Parentheses, brackets, single quotes, and similar items that show up in pairs.
When I watch videos of some people coding, they seem to gracefully whiz by those auto-added closing punctuation marks, so it makes me think there is something I'm missing in how I accept that automated input. Some way that is more zen like than using a right arrow.
Any guidance is much appreciated.

This worked for me;
Go to VS Code settings
Search "autoclose"
Disable "Auto Closing Tags"
Change "Auto Closing Quotes" from 'always' to 'never'
Change "Auto Closing Brackets" from 'always' to 'never'

You have several options:
Type the character that added automatically. For example, if you type { and automatically VS Code added } you can also type } to continue typing whatever you want. VS Code is smart to not doubling the automatically added character
Use End key
Use arrow right key
I think the VS Code team didn't find it needed to add some special key for this need, since all these options are also one key each.

Related

How to remap Tab key to two dots/period key presses

I want to map two dot/period key presses to Tab key in AutoHotkey script. I tried to map similarly as its shown for remapping semicolon key - on AutoHotkey forums, but it doesn't work. I tried following:
1. `..`::Tab
2. ..::Tab
AutoHotkey gives an error
.
I tried searching on AutoHotkey Remap docs, but couldn't figure it out. The period key is the one with the greater than mark and not the number keypad period key. See this: Dot/period key
Addition info/context in response to reply by user 0x464e:
Basically, I am trying to expand Emmet style abbreviations in devtools style sub-panel since the chrome devtools team wont implement it.
I am not a fast typist, so it's a pain to type complete property names. For example, if I want to type margin-top, (see the image), Chrome autocomplete brings up margin, margin-block margin-block-end etc.
Now, for margin-top, you need to at least type margin-t to get the autocomplete to show that property.
This is the case for many very common CSS properties like margins, paddings, etc., so autocomplete isn't great.
On the other hand, if I just type mt and have Autohotkey expand to margin-top, it's much much faster, saves me much time and keeps me sane.
Basically, I have setup some hotstring in .ahk script and they work too.
However, if I press mt followed by a Tab key press, Chrome's autocomplete takes over and hotstring fails, (try once to see the problem). Instead, currently I press spacebar, or . (period) to trigger the hotstring. It works, but the problem is it leaves a space or a dot with the expanded text. [see this].
So, that's the actual reason I wanted a double period key trigger to replace Tab.
It would be great if the hotstring trigger would work with a double period key, but doesn't leave the trigger character itself and then have send Tab so as to jump to the value input of the just expanded property.
You're not really looking for a traditional remap, which is why you didn't find it from the documentation.
Remapping is just simply remapping one key to another, but you're not trying to do that. You're trying to make some action do another action.
Anyway, what you're asking is doable, but there's loads of different ways it can be achieved with difficulties varying from simple to extremely advanced & complicated.
You'll need to specify things more clearly before this can be answered properly.
Biggest questions that pop into my head right away are at least:
Should this work everywhere, or just in text input fields?
How should the original functionality of . be preserved, if at all.
(What should happen after the initial . keypress?)
Should there be some timeout between the keypresses?
Etc, this is just what I could think of right away, but surely there's more.
Anyway, for now I can give a simple implementation with a hotstring:
:*?:..::{Tab}
So this is a hotstring with the * and ? options.
I'm guessing these would probably be pretty good options for this.
So what this does, is it presses backspace twice and sends a Tab if you type ...
This should be fine for text editors, but it leaves much to be desired (the points I listed above aren't considered since I can't know what you're looking for. This is just what a default simple hotstring can offer).
Looks to me like you don't actually want the additional mapping of .. to Tab, but instead just want to update your existing hotstrings to activate immediately (without waiting for an EndChar) when the hotstring is followed by ..
Normally, you might look to the Ending Characters option to create this functionality, but since you want multiple characters to trigger this, we need to look to other options.
I will be using the example of ::mt::margin-top for my sample implementation. Extend any changes I make to these to the rest of your hotstrings in the script you screenshotted.
Here are the changes I am making to this example:
Add your .. to the end of each of your hotstrings triggers. For example ::mt::margin-top becomes ::mt..::margin-top. However, at this present, this still requires some sort of ending character to be pressed in order to proc. Let's fix that in the next step
Add the Asterisk Modifier to the hotstring. From the docs:
* (asterisk): An ending character (e.g. Space, ., or Enter) is not required to trigger the hotstring.
Final code for ::mt::margin-top example:
:*:mt..::margin-top
And extend this * insertion and .. appendation to each of your hotstrings.
Hope this helped! Lmk if you need any more help or changes.

How to jump out of quote or jump out of code block with vim in vscode?

I'm learning Vim for few days and I have a question when coding with vim.
Let say I'm creating an object like this
const person = {
name: "Tu<my pointer after u character>"
}
What is the best way to move my pointer from after u character to after the double quote so I can keep writing my object
Another case is if I finish create object like this
const person = {
name: "Tu<my pointer after u character>"
}
How do I get my pointer to the line after the close curly bracket to keep writing code.
Some people say that I can escape the insert mode and using shift + A to go end of line but it takes 4 buttons to do that?
Thanks for answering my question.
Indeed the way to do it is to escape insert mode and use A to
[A]ppend stuff to the end of the line. To jump to the } in your code, there
are many many options, and which to use depends on the situation and user
preference, but I tend to use something like 3j to move 3 lines down (or
however many I need to move). And by putting the following in my vimrc:
set number
set relativenumber
I always know what number of lines I want to move.
Vim seems a bit weird for about 2 weeks (for me at least, when I started coding
in Vim) but after that it becomes automatic that if I finish inserting text for
any reason, I instinctively hit Esc. Many (most?) vim users remap
the some other key like CapsLock to act like Esc, since the Esc key on
modern keyboards is in an awkward position (unlike in the early days).
Once the 'modal' nature of vim becomes natural for you, things will fall into
place.
Oh, and it really helps if you learn to touch type 100% (i.e. never need to
look at the keyboard - even for numbers, punctuation, 'weird symbols' etc.)
Good luck!
In the first case, press <Right> or <End>, just like in any editor.
In the second case, press <Down> to move the caret after the }, then press <CR> (to open a new line) or <Down> (to move the caret to the line after the }), just like in any editor.
Going back to normal mode just for that is silly.
Note that you wouldn't have to deal with this without whatever you installed that closes quotes automatically.

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 ;)

How to make vscode stop overriding closing parentheses on insertion

When I try to add closing parentheses, it always override the next parentheses to the right.
Here is a screen capture (it looks like I hit the right-key on the keyboard, but I'm actually inserting a new closing parentheses):
Is it possible to change this behavior?
As of version 1.38, the answer is yes, you can turn it off completely, while still keeping the autoclosing brackets.
That version introduced a new setting, editor.autoClosingOvertype, which can take three possible values:
always - always overtype closing parens (the old, classic, Sublime-Text-inspired behavior)
auto - "smart" overtype which tries to detect whether a closing paren was automatically inserted by the editor, and overtypes only those parens (this is the default)
never - never overtype closing parens
The current default behavior was introduced in version 1.37. At that time, there was no setting available, you just got the "smart" overtype behavior no matter what.
I'm leaving the material below for historical purposes.
No, it's not possible (yet), and this is by design. When you are typing brand-new code, and you type an opening bracket, you get the closing bracket automatically (when you have editor.autoClosingBrackets on, of course). Then, when you are finished with typing whatever you want inside those brackets, how are you going to "exit" and leave the closing bracket where it is? The most natural way is to type a closing bracket! Some disagree, but many typists find this much easier than moving their hand all the way out to the arrow keys or mouse to move past it.
Note that this behavior is largely inspired by and modeled after what Sublime Text does.
It may be helpful to understand that the autoclosing brackets feature isn't primarily for saving keystrokes. Rather, its main purpose is to improve the stability of syntax highlighting (which can get wonky when there is an unclosed bracket), and secondarily to help prevent you from forgetting to type the closing bracket. If you happen to navigate away for some other reason without typing it, then congratulations, you do get that bracket for free!
The two simplest options you have if you want to add a bracket (and let me note that in your example, you'd be adding a mismatched bracket) are to either (1) put the cursor after the cluster of closing brackets before you type a new bracket, or (2) put the cursor where you did, but just keep typing closing brackets until a new one is added. In either case, any new brackets will only be added to the end of the cluster.
Update (now obsolete):
For what it's worth, there's now an issue for this on the tracker, as well as a pull request to create a setting which allows you to turn off the "bracket-swallowing". For anyone who is reading this, if it's something you're interested in, you should give your feedback on the pull request.
Further update (now obsolete):
There is currently new code being tested which will make the bracket overtyping more sophisticated. The plan is for the editor to keep track of which brackets have automatically been generated, and only type over those brackets. Once the cursor leaves the bracketed area, the editor stops keeping track of those brackets and they become "full-fledged" characters that can no longer be typed over. Hopefully, this will retain the overtyping where it's useful and get rid of it where it's not. Note that the current plan is for this new behavior to become standard, and to not have a setting to control whether it is in effect.
Try setting:
"editor.autoClosingBrackets": "never"
to disable the autoclosing brackets feature entirely.
Vscode has finally fixed this issue, and you don't need to do anything in order to get the new behaviour. Now it will swallow only brackets that were automatically added, so everything works as expected. If you already disabled the autoClosingBrackets option from the settings, it is recommended to turn it on again now.
The way to work with the VSCode original setting is to add new parenthesis at the end of a list of parenthesis.
...if (test === funFunction(data))| /* <- here */ {...
You should be able to type a new parenthesis and it won't override the old one. This doesn't solve your problem, but if you wanted to follow the paradigm that VSCode is using then there you go.
(personally I disable it like the other comments say)
There's another option available now called autoClosingBrackets beforewhitespace. This will overtype an automatically added parenthesis but it will not overtype of there's any characters to the right of that closing parenthesis. This is perhaps a step closer to the OPs intended behavior, it certainly saved me from going totally bald.