how disabled auto complete on sublime text on specific key? - autocomplete

Each time when I press a key, autocomplete menu apear like this :
That right, but how can I disabled this behaviour on specific key ?
In practice, when I press { for my css in my exemple, after I press ENTER immediatly for make new line (to close it with }), but instead go at line, it's validate the autocomplete (normal behaviour).
How disabled autocomplete on specials key like { [ ?

override key :
{ "keys": ["altgr+'"], "command": "insert_snippet", "args": {"contents": "{"}},
TIPS: use sublime.log_input(True) in console to find real key pressed (in this case ' instead of {)

Related

How can I get line break on enter even when the search field is open (but not focused) in VS Code?

If I have the search field open and press enter in my code it automatically tries to search instead of giving me a line break. I've heard that there is a way to turn off this behavior and only search when the search field has focus. Anyone know how? Currently I have to hit ESC to close the search before I can add a line break and I forget to do it 95% of the time and my editor jumps to a different section of the code. Thanks!
Changing findWidgetVisible to findWidgetFocus in my keyboard shortcuts settings fixed it!
/**
* amVim Finder Fix
**/
{
"key": "enter",
"command": "editor.action.nextMatchFindAction",
"when": "findWidgetFocus"
},
{
"key": "shift+enter",
"command": "editor.action.previousMatchFindAction",
"when": "findWidgetFocus"
},

Selecting text code visualstudio with hot key

I installed code visualstudio 1.54.1 and having some line of code
if cursor is located on string
$adImageItemImgProps = AdImage::readAdImageProps($adImageItem->ad_id, $adImageItem->image, true);
inside of readAdImageProps method name, but when no chars selected and clicking hot key
all readAdImageProps method name is selected
and next clicking hot key
AdImage::readAdImageProps is selected.
and so on...
In similar way in PhpStorm work hot keys Ctrl+W...
MODIFIED :
I manually added proposed key lines in /home/username/.config/Code/User/keybindings.json
and see in the file : https://prnt.sc/10lc240
I restarted code visualstudio and "ctrl+shift+alt+w" and this function works in not way I expect.
Say I have in control php file with no test selected : https://prnt.sc/10lc53f
When I click "ctrl+shift+alt+w" - it works as I expect only for the first time : https://prnt.sc/10lc77h
But not next time when I clcik trhis hot key : https://prnt.sc/10lc7w0 and https://prnt.sc/10lc8xr
Is something wrong in my config ?
Thanks!
You can use the extension Select By
It is a 2 phase solution.
If no selection yet use the command editor.action.addSelectionToNextFindMatch to select the word under the cursor
If selection then extend at the begin to the next parent scope
Ad this to your keybindings.json file
{
"key": "ctrl+shift+alt+w",
"when": "editorTextFocus && !editorHasSelection",
"command": "editor.action.addSelectionToNextFindMatch"
},
{
"key": "ctrl+shift+alt+w",
"when": "editorTextFocus && editorHasSelection",
"command": "selectby.regex",
"args": {
"backward": "[a-zA-Z0-9_]+::",
"backwardInclude": true
}
}
Edit
I removed the forward search because it was taken care of by the no-selection case.

VSCode keyboard shortcut to navigate from search bar to highlighted selection

I'm constantly searching code within a file in VSCode.
Is there a keyboard shortcut to navigate from the search bar to the highlighted selection in the editor? That would make things much more efficient for me.
I know I can copy a highlighted selection from the editor to the search bar using CMD + F.
If you are talking about moving from the find widget to the first match, it looks like you have this option, assuming you don't want to just close the find widget with escape:
the workbench.action.focusActiveEditorGroup command is unbound you could use that. But you have to hit escape twice to unselect the find match if you don't want it to remain selected.
That's a pain though so you might a macro that does it all at once. Like (in settings):
"multiCommand.commands": [
{
"command": "multiCommand.focusEditorFromFind",
"sequence": [
"workbench.action.focusActiveEditorGroup",
"cancelSelection",
"cancelSelection",
]
}
]
and keybindings.json:
{
"key": "shift+e",
"command": "multiCommand.focusEditorFromFind",
"when": "editorFocus && findWidgetVisible"
}
So after typing your find term, just Enter until you get to the particular find match you want to switch focus to, and the Shift+E or whatever keybinding you go with above.
Maybe I am just missing it but it seems odd there isn't an easier way to toggle focus from the find widget.

VS code autocompletion customization - do not automatically select any suggestion

I would like to customize VScode autocompletion behaviour to suit my liking.
Namely:
When the suggestions list appears, I don't want any suggestion to be selected.
When I press Tab and Shift-Tab, I want to cycle through the suggestions (thus selecting one). Esc should unselect any selected suggestion (and can close the suggestions list, optionally).
When a suggestion is selected, any character should accept that suggestion (so edit my code with the text of that suggestion).
Item 2. is achieved by editing the keybinds.
I haven't found a way to get the behaviour of item 1.
For item 3., a dirty hack could be to exploit the editor.acceptSuggestionOnCommitCharacter setting, and using all characters as commit characters, but I haven't found how to edit which characters are commit characters.
Is there a way to achieve this behaviour using the settings?
If not, is there an extension that provides this behaviour?
Ideally, I would like to avoid coding my own extension, but I could resort to that if no other solution is available.
Note: this question is different from this one, because I do not want to press Return to accept a suggestion (unless i want to accept the suggestion and insert a new line).
edit: I believe this answer can implement item 3 using the dirty hack described above, I just have to copy the same keybind for all possible characters with the same "when" conditions, now I just need to find a way to get item 1. (and ideally find a better way to get item 3.).
edit again: to make my question clearer, I've recorded the desired behaviour from vim, with the keys pressed.
For item 1, you could press the up-arrow key de-select a suggestion.
or you could go to VSC, From Visual Studio, select “Tools” > “Options“.
Select “Text Editor” in the left pane.
Select the language you are using (C#, C++, Basic, etc.).
For C# and Basic, choose “IntelliSense“. ...
For C# and Basic, check the “Show completion list after a character is typed” to disable it.
For the 3rd item, you could just not write any parenthesis, < or >, { or }, [ or ], or < and >.
instead, just write what's inside of these. And the auto completion will put every sign in it's right place.
Hope I helped!
I'm also looking for the same. But the closest I came was to preview the suggestion, which I turned on: Put this in your settings.json in VScode
"editor.suggest.preview": true
But I don't think the actual insert feature is available in VScode yet.
for item 2:
first you will need to disable selecting a suggestion with Enter. for that, change the keybinding for "insertSnippet"
{
"key": "enter",
"command": "insertSnippet",
"when": "editorTextFocus && hasSnippetCompletions && !editorTabMovesFocus && !inSnippetMode"
},
then, to add navigation with Tab and Shift + Tab modify "selectNextSuggestion" and "selectPrevSuggestion"
*make sure that both shortcuts have "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
{
"key": "down",
"command": "-selectNextSuggestion",
"when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
},
{
"key": "shift+tab",
"command": "selectPrevSuggestion",
"when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
},
for exiting the snippet selection Esc should alredy be the default key. If that's not the case, modify the "leaveSnippet" keybinding.
{
"key": "escape",
"command": "leaveSnippet",
"when": "editorTextFocus && inSnippetMode"
},
There is a new approach to how suggestions are handled coming in vscode v1.75, see Implement "Suggestion Mode" from Visual Studio. New setting:
Editor > Suggest: Selection Mode
Controls whether a suggestion is selected when the widget shows. Note
that this only applies to automatically triggered suggestions
(Editor: QUick Suggestions and Editor: Suggest on Trigger Characters) and that a suggestion is always selected when explicitly
invoked, e.g. via Ctrl+Space.
Options:
always Always select a suggestion when automatically Intellisense
never Never Always select a suggestion when automatically Intellisense
whenTriggerCharacter Select a suggestion only when triggering Intellisemse from a trigger character
whenQuickSuggestion Select a suggestion only when triggering Intellisense as you type
Demo 1: modes never and always - note that with never there is no selected item in the suggestion box and when I press Enter or Tab a newline is inserted into the code. Option always has a selected suggestion item automatically and Enter selects and inserts that.
Demo2: mode whenTriggerCharacter, note that although suggestions are shown none are selected and I can Enter and Tab and they are inserted. Only when a trigger character like . is entered is a suggestion selected and Enter and Tab will insert that selected suggestion item into the code (depending on your setting regarding using Enter as a suggestion completion).
Demo3: mode whenQuickSuggestion You will get selected suggestions as you type, except for trigger characters. Trigger characters will still show suggestions but none will be selected so you can Enter and Tab.
Note that in all cases above where there are suggestions shown but none are selected the DownArrow and UpArrow keys will scroll and select items in the suggestions.
There is another demo at the link above: https://github.com/microsoft/vscode/issues/139825#issuecomment-1364056148

VSCode key binding for next editor in stack

In Sublime I have a keybinding set up like so:
{ "keys": ["super+j"], "command": "next_view_in_stack" },
I am trying to recreate this behavior in VSCode with
{
"key":"cmd+j",
"command":"workbench.action.previousEditor"
},
but instead of going to my previous tab, it goes one tab to the left. Is there any concept of a "stack" of editors like in Sublime?
You need to configure two different key bindings to get this working correctly.
First configure workbench.action.quickOpenPreviousRecentlyUsedEditorInGroup to Cmd + J, and set its when expression to !inQuickOpen.
Also, to allow using the shortcut repeatedly once the quick open list is already open, you need to also configure workbench.action.quickOpenNavigateNext to Cmd + J, and set its when expression to inQuickOpen.
For me this worked when I wanted to configure Alt + Tab for the recent file cycling shortcut. Hope this helps.
There are the following commands that may give you the functionality you're looking for:
{ "key": "ctrl+tab", "command": "workbench.action.openNextRecentlyUsedEditorInGroup" },
{ "key": "ctrl+shift+tab", "command": "workbench.action.openPreviousRecentlyUsedEditorInGroup" },
use
'alt + leftArrow' & 'alt + rightArrow" // switch between recent stack tabs