Is there an equivalent to editor.actions.indentLines that moves the selected lines to the left instead of to the right?
I know you can use Tab / Shift+Tab for indenting. But unfortunately, that does not work in Vim mode.
That is called "outdenting". See the command:
{
"key": "shift+tab",
"command": "outdent",
"when": "editorTextFocus && !editorReadonly && !editorTabMovesFocus"
}
Just set it to a different keybinding. You can search for "shift tab" in the keybindings to try to figure out what command it is already bound to - in this case "outdent".
EDIT: Actually I see that Ctrl-[ is already bound to outdent so you could try that as well.
No, there isn't. You have editor.action.reindentLines but instead of working as Shift + Tab, it resets the indentation.
There is an open issue (Help Sublime Text users migrate to VS Code) which seems to be mapping this. You could upvote there and maybe comment, asking for the VS Code team to add this command as well.
Related
I've set up shift+enter in VSCode to send a selected line(s) to a Python terminal. No other command is set to use shift+enter as its keybinding.
If I highlight some lines, right click, and select Run Selection/Line in Python Terminal, everything operates successfully. But when I try to use the specified keybinding (here shift+enter), the selection is disappeared by enter. No custom keybinding seems to send the selection to the Python terminal.
I don't understand what's causing this behavior and my knowledge of VSCode as anything other than a user is fairly limited. The custom keybinding exists in my keybindings.json file as
{
"key": "shift+enter",
"command": "python.execSelectionInTerminal",
"when": "editorFocus && !findInputFocussed && !python.datascience.ownsSelection && !replaceInputFocussed && editorLangId == 'python'"
}
The entries into keybindings.json override the VS code defaults. Try deleting your entry and it should revert to the default behaviour, which does what you're looking for.
Due to the entries in your "when" key, it looks as though you're trying to do interactive data science. If that is your goal, instead/also try:
In VS Code Settings, find and enable:
Python > Data Science: Send Selection To Interactive Window
Determines if selected code in a python file will go to the terminal or the Python interactive window when hitting shift+enter
Whilst coding I frequently find myself needing to jump either to the top or bottom of a file, but I can't find a quick way to do this with a single key stroke. I tried to define a short cut in the key bindings, but I can't find a function like "page-home" and "page-end". I was going to use the alt key with the home button to jump to the top of a page and alt+end for the bottom.
ie I was expecting to be able to define say:
{ "key": "alt+home", "command": "[what is page home command]", "when":
"terminalFocus"}
So, are there such functions page-home/page-end (I may have this wrong, perhaps its defined as something else).
I've spotted a binding for "cmd+home" bound to "workbench.action.terminal.scrollToTop" which sounds like the right function (and a similar one for "cmd+end"), but they don't work.
UPDATE: I've tried to apply changes to the keybindings via the key bindings page, by defining the keystrokes I mentioned before, and it still does not work. Unless I'm doing something wrong, I . think there is a bug that needs to be reported, unless somebody can say otherwise.
Thanks.
The answer is in this GitHub post. The commands you're looking for are cursorTop and cursorBottom.
Open up the command palette (CTRL + SHIFT + P on Windows) and select Preferences: Open Keyboard Shortcuts File
Add in the following settings in keybindings.json:
{
"key": "ctrl+home",
"command": "cursorTop",
"when": "editorTextFocus"
},
{
"key": "ctrl+end",
"command": "cursorBottom",
"when": "editorTextFocus"
}
replacing the key with whatever shortcut you prefer.
In Visual Studio code, you can use a keyboard shortcut to create multiple cursors above and below the current line, allowing to edit on multiple spots in the code. See also the docs
However, once you have done your multiline edits, how does one clear the multiple cursors, using a keyboard shortcut?
keybindings.json (instead of ctrl+; you can use your keybinding):
{
"key": "ctrl+;",
"command": "removeSecondaryCursors",
"when": "editorHasMultipleSelections && editorTextFocus"
},
{
"key": "escape",
"command": "-removeSecondaryCursors",
"when": "editorHasMultipleSelections && editorTextFocus"
}
If I'm not mistaken you're asking how to exit multiline edit mode? I believe you simply press esc
I can view side-by-side comparison to current and previous file version in VS Code Source Control/Git View. Are there any hotkey's to navigate on my changes i.e. go to next/prev changes from the keyboard just as if I clicked the Next Change button?
Unfortunately I haven't found anything about it in the key binding documentation page
To go to the next difference use Alt + F5.
To go to the previous difference use Shift + Alt + F5.
You are looking for workbench.action.compareEditor.nextChange/previousChange.
I have it bound to ctrl + down like this:
{
"key": "ctrl+down",
"command": "workbench.action.compareEditor.nextChange",
"when": "textCompareEditorVisible"
}
If anyone here for Visual Studio 2019:
You will go on changes directly in file (In Visual Studio 2019).
Next Change in current file:
You can simply press F8 Key for go to Next Change.
Previous Change in current file:
You can simply press Shift + F8 Key for go to Previous Change.
"when": "textCompareEditorVisible" works perfectly in most cases. But when there is any conflict on the keybinding, && isInDiffEditor is a way, which makes the keybinding work only in diff editor.
{
"key": "cmd+up",
"command": "workbench.action.compareEditor.previousChange",
"when": "textCompareEditorVisible && isInDiffEditor"
},
{
"key": "cmd+down",
"command": "workbench.action.compareEditor.nextChange",
"when": "textCompareEditorVisible && isInDiffEditor"
}
In my case, my keybindings in integrated terminal will be broken if I don't append the condition
The default on OSX/mac is alt + F5 for next and alt + shift + F5 for previous.
Note:
Make sure you have deactivated your fn keys on mac, so you can fully use VS-Codes shortcuts.
I am used from Pycharm to be able to press ctrl + click on a function definition and see the uses. Is there an equivalent in VSC?
you can use shift+f12 for get better view of usage
https://github.com/Microsoft/vscode-tips-and-tricks
read this and you can get better idea
2020-03-05 update
You can CTRL+CLICK (Windows) or CMD+CLICK (Mac) on the function name and look on the right column.
Right-click and select "Go to References" or "Find All References" from context menu:
There is, but VSCode doesn't support key bindings with mouse buttons. The relevant issue is #3130. That means that it will not work the same way as it works in PyCharm.
What You can do though is to use - I believe - ShiftF12 or set some key combination to show all usages of function.
To do this You can press CtrlK, then CtrlS and click on 'keybinding.json' link in the sentence: "For advanced customization open and edit keybinding.json".
After getting keybinding.json open, add the following entry there.
{
"key": "ctrl+shift+d",
"command": "editor.action.referenceSearch.trigger",
"when": "editorHasReferenceProvider && editorTextFocus && !inReferenceSearchEditor"
}
It should let You show usages of function by pressing CtrlShiftD. Obviously, You can customize it however You like.
I also recommend adding the following entry to close the dialog with the same key combination.
{
"key": "ctrl+shift+d",
"command": "closeReferenceSearch",
"when": "referenceSearchVisible && !config.editor.stablePeek"
}