Why VS Code showing suggestion even if they are not related to words and apparently also applying them after entering shift + 9? - visual-studio-code

I am trying to learn gulp and so I am using rename() method but VS Code is showing those unrelated suggestion as shown in the image and as I am typing shift + 9 to make brackets for the method, the first suggestion is getting applied instead of rename() and it is changing to requestAnimationFrame(). Why this behavior is happening and how can I fix this ?
https://i.stack.imgur.com/K2qdt.jpg

( is treated as commit character for method suggestion. Typing it will accept the current suggestion.
Press escape to cancel out of the current suggestion before pressing ( or disable commit characters entirely by setting "editor.acceptSuggestionOnCommitCharacter": false

Related

VSCode snippets (Hypersnips) tab stops in nested use of snippets

I am using VSCode Hypersnips (based off of Vi's https://github.com/SirVer/ultisnips), following this guide . See also Create-Snippets-For-Ultisnips.
Consider the following example: I have a snippet
snippet fm "inline Math" wA
\(${1}\) $0
end snippet
and another snippet
snippet ( "parenthesis" wiA
($1) $0
end snippet
If I were to type fm, then that would produce \(|\) |, where the first | is where my cursor is, and the second | is where my cursor would be if I pressed <Tab>. Now, when I type fm ( hi <Tab> that produces \((hi) |\) as expected, but when I press <Tab> again (hoping to use the $0 tab stop of the fm snippet), I don't get outside the right \) like I want, and instead a tab character (i.e. 2 spaces) are placed where the cursor is.
I am wondering if I can nest snippets like this, and still use the tab stops of the outer snippet once I exit the inner snippet.
I assume the same issue occurs if I use native VSCode snippets.
StackOverflow informs me that a similar question has been asked: Atom - Nested snippets with tab stops error, but not about VSCode's snippets.
It seems this is known issue: https://github.com/draivin/hsnips/issues/78. This is a summary of the issue from Dec. 2 2021:
So, I looked into it, the placeholder disappearance is caused by a
workaround we are currently using to get around a VsCodeVim issue.
History time:
We started using the workaround to get around this issue Trigger A leaves me in visual mode, I want it to leave me in insert
mode instead #28.
Supposedly, the related issue in VSCodeVim was fixed
here Snippet is not working Properly VSCodeVim/Vim#5240.
I'm not sure
if it was never properly fixed, or if a regression happened, but it
seems that the issue still exists (see Unexpectedly entered visual
mode in snippet VSCodeVim/Vim#7068), so while that issue is still
open, we can't remove the workaround and fix this bug.
For now, https://github.com/draivin/hsnips/issues/126 offers what I think is the best solution, namely using VSCode Neovim.

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?

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.

Why is vscode auto-completing import suggestions on left parentheses?

Seems like an odd "confirmation" trigger, given that I have to type those quite often for unrelated functions, etc.
As Daniel M mentioned, since I'm referencing a test global vscode isn't aware and tries to guess the function I'm typing.
Solution is to add jest types:
yarn add --dev #types/jest
Extensions that provide intellisense can define "commit characters" that accept the current suggestion when typed. VS Code's JS and TS support marks . as a commit character for all suggestions, as well as treating ( as a commit character for function/method suggestions.
To prevent this, either press esc to cancel out of the suggestion dialog before typing (, or set:
"editor.acceptSuggestionOnCommitCharacter": false
to disable commit characters entirely.

VS Code: Case sensitive replacement after pressing Crtl - D

Let's suppose I have the following code:
But I change my mind and I don't want to call it plan anymore. I want to call it schedule. So, because VS Code is so amazing and I'm so lazy, I press Ctrl + D hoping for VS Code to change the name respecting the case. But suddenly:
Is it there any way to tell VS Code to respect the case?
With 1.37 (July 2019), it is possible through a find/replace (which now can replace by preserving case).
Issue 9798 has been implemented by PR 78003.
issue 78397 has been implemented by PR 79111 (1.38 only) for search/replace.
From 1.37 release notes:
You can now preserve case when doing replacement in the editor's Find widget. The feature is turned on when the Preserve Case option (AB button) is turned on in the editor's Replace input box.
Currently VS Code only supports preserve Full Upper Case, Full Lower Case, and Title Case.
Shortcuts are Alt + C for case sensitive. There is a little toolbar appears at the top-right corner of the VS Code, to let you toggle search options.
or you just Ctrl + F to toggle replace mode.
The v1.38 release in early September will extend the Preserve Case functionality to replacements while searching across files using the Search Panel. See add Preserve Case to Searches (all files).
.
There is also a new case preservation mode for hyphen-separated words.
v1.39 is adding preserve case for _underscore separated words. Like foo_bar.
See https://github.com/microsoft/vscode/pull/79660
If you want to achieve this without using the find/replace menu, there is an extension which solves your problem: https://marketplace.visualstudio.com/items?itemName=Cardinal90.multi-cursor-case-preserve
As far as I know it isn't, a workaround could be using the buttons that appear on top right after you press Ctrl + D. The second lets you select occurrences respecting the case, this way you could replace the text in 2 steps, first Plan and then plan.
So select the code bit, ctrl+h to open replace, edit find and replace, turn off match case in find, turn on preserve case within replace, Alt+L to find all occurences in selection, and Ctrl+Alt+Enter to execute.
9/10 cases you'll get it wrong, doesn't worth the effort. Just use ctr+d, then do the same for the uppercase.
Personally looking forward for a simpler/safer solution through the ctrl+d way. :)

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