I want to be able to edit the same file while reading lines way ahead of current line. Given nowadays we do chaining, this vertical is not what I want
What I want is the other way.
It took me heck of time to find out the name "workbench.editor" something who controls it. But VSC version update erased it. It can't be found at setting now. Current VSC 1.38.1.
If you want to rebind the split editor command, try this in your keybindings.json:
{ // unbind the default split keybinding
// probably unnecessary to do this but I suggest it
"key": "ctrl+\\",
"command": "-workbench.action.splitEditor"
}
{ // reset the split command to horizontal split
"key": "ctrl+\\",
"command": "workbench.action.splitEditorDown"
}
It won't have any effect on the action of the split editor icon - it is unclear if that is what you want.
Changing the keybinding will result in Ctrl+\ now splitting horizontally instead of to the right.
As #Jeb50 pointed out in the comment, you can change the split editor icon appearance and functionality by Open Side by Side Direction setting. This is demonstrated below:
Select View > Editor Layout > Split Down.
There are many options.
Example Here!
Related
I want to save my current cursor position, move to some other line (in the same file), do some editing and jump back to the original cursor position to continue coding.
Lets say i am in line 50 and realise i need to add a header/library file at line 5. I want save my position here so that i can jump back after making my changes at line 5. How can i do this?
I have looked into cursor navigation shortcuts but they all move cursor by tracing every position cursor was in, and its time consuming and confusing, instead i want to jump back to saved position in one shot.
You could use the selection anchor. There is no default keybinding for "Go to Selection Anchor" so you'd have to add one yourself.
There is no built-in command for that. The Go Back / Go Forward navigation commands doesn't allows you to save specific locations.
Instead, you should rely on extensions, like my Bookmarks extensions.
There is a bunch of other similar extensions, as you can see on this search https://marketplace.visualstudio.com/search?term=bookmarks&target=VSCode&category=All%20categories&sortBy=Relevance. You should take a look at some, and try out the one that better fit our needs.
Hope this helps
Thanks #scottfrazer for the suggesting selection anchor.
Thanks #alefragnani for suggesting extensions.
Based on these answers, i wrote a keybinding using multi command extension,
After installing the multi command extension,
Add the following snippets in the keybindings.json,
[
{
"key": "ctrl+alt+`",
"command": "extension.multiCommand.execute",
"when": "!selectionAnchorSet",
"args": {
"sequence": [
"editor.action.setSelectionAnchor",
]
}
},
{
"key": "ctrl+alt+`",
"command": "extension.multiCommand.execute",
"when": "selectionAnchorSet",
"args": {
"sequence": [
"editor.action.goToSelectionAnchor",
"editor.action.cancelSelectionAnchor",
]
}
},
]
Above snippet will create a key binding for "ctrl+alt+`" (Ctrl + Alt + BackTick).
When pressed,
Creates a selection anchor at cursor position
If an anchor already exists, Move to that cursor position and deletes that anchor at that position.
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.
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
I have VS Code on Win8.1.
I really don't like how the signature box opens up over the surrounding code in the editor. I do like the intellisense box. On the page (link above) it says Ctrl+Shift+Space to manually trigger signature help. But how can I close it? The problem is that it opens up without me triggering it.
I know I can close it by moving the cursor out from the function block. But that is a pain to have to do that all the time. I wish Ctrl+Shift+Space could toggle the box.
I remember when I used Visual Studio. There was a key-short-cut to toggle or to get opacity on the boxes. That was great. Is that possible in VS Code?
It is for JavaScript/React (if that's important)
EDIT:
I found an answer on Reddit that don't give me the good solution Visual Studio has. But it makes the box a bit transparent. But it is always transparent. Here is the solution for the half-way-workaround (cut-and-past from the reddit-post, user: tgreen7):
I found a way to do this in settings. if you go here https://code.visualstudio.com/docs/getstarted/theme-color-reference and search for "editorSuggestWidget.background" that is the setting you are looking to change.
So for example my background was originally the hex color: #21252B
And I changed my settings like so:
"workbench.colorCustomizations": {
"editorSuggestWidget.background": "#21252BAA"
}
and now my suggestion window has opacity. You can adjust the last two digits of the hex number to get your desired transparency (opacity).
escape will close it, and then Ctrl+shift+space to get it back.
If you want a toggle try this with whatever keybinding you want:
{
"key": "ctrl+shift+space", // whatever, even "escape"
"command": "editor.action.triggerParameterHints",
"when": "editorHasSignatureHelpProvider && editorTextFocus"
},
{
"key": "ctrl+shift+space", // use same keybinding as above here fro toggle
"command": "closeParameterHints",
"when": "editorHasSignatureHelpProvider && editorTextFocus && parameterHintsVisible"
},
I know I can use the Cmd-Opt-O shortcut key to change the split layout, but I want it to default to horizontal splits. I can't find a setting for this. Does anyone know if this is possible in VS Code?
From 1.25 version there are commands to split editor in 4 directions. Example keybindings.json
{
"key": "ctrl+\\",
"command": "workbench.action.splitEditorDown",
},
workbench.action.splitEditorUp
workbench.action.splitEditorDown
workbench.action.splitEditorLeft
workbench.action.splitEditorRight