There is a Stage Selected Lines
button for Git, but is there a way to add a keyboard shortcut for it?
It is too much trouble having to click twice (three dots
> Stage Selected Lines
).
There is a Stage Selected Lines
button for Git, but is there a way to add a keyboard shortcut for it?
It is too much trouble having to click twice (three dots
> Stage Selected Lines
).
In case anyone is still looking for this:
The commands stageSelectedRanges
, unstageSelectedRanges
, revertSelectedRanges
have been introduced a while ago. Note that there is currently a related bug in VSCode: the diff view does not refresh after a partial stage - but apart from that it works like a charm.
This is how I set it up in my keybindings:
{
"key": "s",
"command": "git.stageSelectedRanges",
"when": "isInDiffEditor && editorTextFocus"
},
{
"key": "u",
"command": "git.unstageSelectedRanges",
"when": "isInDiffEditor && editorTextFocus"
},
{
"key": "r",
"command": "git.revertSelectedRanges",
"when": "isInDiffEditor && editorTextFocus"
}
git.revertSelectedRanges
is more like "discard" - has nothing to do with git revert
, does not work in read-only text buffers –
Radial The accepted answer didn't work for me so I raised a ticket on GitHub:
When condition for Source Control View for better keybindings #99683
The following did:
{
"key": "ctrl+a",
"command": "git.stageAll",
"when": "sideBarFocus && activeViewlet == 'workbench.view.scm'"
},
{
"key": "ctrl+s",
"command": "git.stage",
"when": "sideBarFocus && activeViewlet == 'workbench.view.scm'"
},
{
"key": "ctrl+u",
"command": "git.unstage",
"when": "sideBarFocus && activeViewlet == 'workbench.view.scm'"
},
UPDATE:
I was also able to get single keys working via the addition of the listFocus
attribute:
{
"key": "s",
"command": "git.stage",
"when": "listFocus && sideBarFocus && activeViewlet == 'workbench.view.scm'"
},
Visual Studio Code gives you the ability to bind a keyboard shortcut for staging an entire file (workbench.action.git.stage
command).
As far as I know, there is no (publicly documented) workbench command for staging selected lines, thus we have nothing to bind a keyboard shortcut to.
As of October 2016, the Default Keyboard Shortcuts file of visual-studio-code contains the following commands (as @Brynden Bielefeld mentionned, there is no stageSelectedLine
):
acceptQuickFixSuggestion
acceptRenameInput
acceptSelectedSuggestion
acceptSelectedSuggestionOnEnter
acceptSnippet
actions.find
cancelRenameInput
cancelSelection
closeAccessibilityHelp
closeBreakpointWidget
closeFindWidget
closeMarkersNavigation
closeParameterHints
closeQuickFixWidget
closeReferenceSearch
closeReferenceSearchEditor
compositionEnd
compositionStart
cursorBottom
cursorBottomSelect
cursorColumnSelectDown
cursorColumnSelectLeft
cursorColumnSelectPageDown
cursorColumnSelectPageUp
cursorColumnSelectRight
cursorColumnSelectUp
cursorDown
cursorDownSelect
cursorEnd
cursorEndSelect
cursorHome
cursorHomeSelect
cursorLeft
cursorLeftSelect
cursorPageDown
cursorPageDownSelect
cursorPageUp
cursorPageUpSelect
cursorRight
cursorRightSelect
cursorTop
cursorTopSelect
cursorUndo
cursorUp
cursorUpSelect
cursorWordEndLeft
cursorWordEndLeftSelect
cursorWordEndRight
cursorWordEndRightSelect
cursorWordLeft
cursorWordLeftSelect
cursorWordRight
cursorWordRightSelect
cursorWordStartLeft
cursorWordStartLeftSelect
cursorWordStartRight
cursorWordStartRightSelect
cut
default:compositionEnd
default:compositionStart
default:cut
default:paste
default:replacePreviousChar
default:type
deleteAllLeft
deleteAllRight
deleteLeft
deleteRight
deleteWordEndLeft
deleteWordEndRight
deleteWordLeft
deleteWordRight
deleteWordStartLeft
deleteWordStartRight
editor.action.addCommentLine
editor.action.addSelectionToNextFindMatch
editor.action.addSelectionToPreviousFindMatch
editor.action.blockComment
editor.action.changeAll
editor.action.clearoutput
editor.action.clipboardCopyAction
editor.action.clipboardCutAction
editor.action.clipboardPasteAction
editor.action.commentLine
editor.action.copyLinesDownAction
editor.action.copyLinesUpAction
editor.action.defineKeybinding
editor.action.deleteLines
editor.action.detectIndentation
editor.action.findReferences
editor.action.format
editor.action.goToDeclaration
editor.action.indentationToSpaces
editor.action.indentationToTabs
editor.action.indentLines
editor.action.indentUsingSpaces
editor.action.indentUsingTabs
editor.action.inPlaceReplace.down
editor.action.inPlaceReplace.up
editor.action.insertCursorAbove
editor.action.insertCursorAtEndOfEachLineSelected
editor.action.insertCursorBelow
editor.action.insertLineAfter
editor.action.insertLineBefore
editor.action.jumpToBracket
editor.action.marker.next
editor.action.marker.prev
editor.action.moveCarretLeftAction
editor.action.moveCarretRightAction
editor.action.moveLinesDownAction
editor.action.moveLinesUpAction
editor.action.moveSelectionToNextFindMatch
editor.action.moveSelectionToPreviousFindMatch
editor.action.nextMatchFindAction
editor.action.nextSelectionMatchFindAction
editor.action.openDeclarationToTheSide
editor.action.openLink
editor.action.outdentLines
editor.action.previewDeclaration
editor.action.previousMatchFindAction
editor.action.previousSelectionMatchFindAction
editor.action.quickFix
editor.action.referenceSearch.trigger
editor.action.removeCommentLine
editor.action.rename
editor.action.replaceAll
editor.action.replaceOne
editor.action.selectAll
editor.action.selectAllMatches
editor.action.selectHighlights
editor.action.showAccessibilityHelp
editor.action.showContextMenu
editor.action.showHover
editor.action.showSnippets
editor.action.smartSelect.grow
editor.action.smartSelect.shrink
editor.action.sortLinesAscending
editor.action.sortLinesDescending
editor.action.startFindReplaceAction
editor.action.toggleRenderControlCharacter
editor.action.toggleRenderWhitespace
editor.action.toggleTabFocusMode
editor.action.toggleWordWrap
editor.action.triggerParameterHints
editor.action.triggerSuggest
editor.action.trimTrailingWhitespace
editor.debug.action.conditionalBreakpoint
editor.debug.action.runToCursor
editor.debug.action.selectionToRepl
editor.debug.action.selectionToWatch
editor.debug.action.showDebugHover
editor.debug.action.toggleBreakpoint
editor.emmet.action.balanceInward
editor.emmet.action.balanceOutward
editor.emmet.action.decrementNumberByOne
editor.emmet.action.decrementNumberByOneTenth
editor.emmet.action.decrementNumberByTen
editor.emmet.action.evaluateMath
editor.emmet.action.expandAbbreviation
editor.emmet.action.incrementNumberByOne
editor.emmet.action.incrementNumberByOneTenth
editor.emmet.action.incrementNumberByTen
editor.emmet.action.matchingPair
editor.emmet.action.mergeLines
editor.emmet.action.nextEditPoint
editor.emmet.action.previousEditPoint
editor.emmet.action.reflectCSSValue
editor.emmet.action.removeTag
editor.emmet.action.selectNextItem
editor.emmet.action.selectPreviousItem
editor.emmet.action.splitJoinTag
editor.emmet.action.toggleComment
editor.emmet.action.updateImageSize
editor.emmet.action.updateTag
editor.emmet.action.wrapWithAbbreviation
editor.fold
editor.foldAll
editor.foldLevel1
editor.foldLevel2
editor.foldLevel3
editor.foldLevel4
editor.foldLevel5
editor.foldRecursively
editor.unfold
editor.unfoldAll
editor.unFoldRecursively
expandLineSelection
extensions.update-all
hideSuggestWidget
insertSnippet
jumpToNextSnippetPlaceholder
jumpToPrevSnippetPlaceholder
leaveSnippet
lineBreakInsert
markdown.showPreview
markdown.showPreviewToSide
outdent
paste
redo
removeSecondaryCursors
repl.action.acceptInput
repl.action.historyNext
repl.action.historyPrevious
replacePreviousChar
scrollLineDown
scrollLineUp
scrollPageDown
scrollPageUp
search.action.replaceAll
selectNextPageQuickFix
selectNextPageSuggestion
selectNextQuickFix
selectNextSuggestion
selectPrevPageQuickFix
selectPrevPageSuggestion
selectPrevQuickFix
selectPrevSuggestion
setContext
showNextParameterHint
showPrevParameterHint
tab
toggleExperimentalScreenReaderSupport
toggleFindCaseSensitive
toggleFindRegex
toggleFindWholeWord
toggleSuggestionDetails
type
undo
workbench.action.acceptSelectedQuickOpenItem
workbench.action.appPerf
workbench.action.clearEditorHistory
workbench.action.closeActiveEditor
workbench.action.closeAllEditors
workbench.action.closeEditorsInGroup
workbench.action.closeEditorsInOtherGroups
workbench.action.closeEditorsToTheLeft
workbench.action.closeEditorsToTheRight
workbench.action.closeFolder
workbench.action.closeMessages
workbench.action.closeOtherEditors
workbench.action.closeQuickOpen
workbench.action.closeWindow
workbench.action.closeWindow
workbench.action.compareEditor.nextChange
workbench.action.compareEditor.previousChange
workbench.action.configureLocale
workbench.action.cycleEditor
workbench.action.debug.configure
workbench.action.debug.continue
workbench.action.debug.disconnect
workbench.action.debug.pause
workbench.action.debug.restart
workbench.action.debug.run
workbench.action.debug.start
workbench.action.debug.stepBack
workbench.action.debug.stepInto
workbench.action.debug.stepOut
workbench.action.debug.stepOver
workbench.action.debug.stop
workbench.action.editor.changeEncoding
workbench.action.editor.changeEOL
workbench.action.editor.changeLanguageMode
workbench.action.evenEditorWidths
workbench.action.files.copyPathOfActiveFile
workbench.action.files.newFile
workbench.action.files.newFolder
workbench.action.files.newUntitledFile
workbench.action.files.openFile
workbench.action.files.openFolder
workbench.action.files.revealActiveFileInWindows
workbench.action.files.revert
workbench.action.files.save
workbench.action.files.saveAll
workbench.action.files.saveAs
workbench.action.files.saveFiles
workbench.action.files.showOpenedFileInNewWindow
workbench.action.focusFirstEditor
workbench.action.focusFirstEditorGroup
workbench.action.focusLeftEditor
workbench.action.focusNextGroup
workbench.action.focusPanel
workbench.action.focusPreviousGroup
workbench.action.focusQuickOpen
workbench.action.focusRightEditor
workbench.action.focusSecondEditor
workbench.action.focusSecondEditorGroup
workbench.action.focusSideBar
workbench.action.focusThirdEditor
workbench.action.focusThirdEditorGroup
workbench.action.git.globalOpenChange
workbench.action.git.globalOpenFile
workbench.action.git.input-commit
workbench.action.git.publish
workbench.action.git.pull
workbench.action.git.push
workbench.action.git.stage
workbench.action.git.startGitBranch
workbench.action.git.startGitCheckout
workbench.action.git.sync
workbench.action.git.undoLastCommit
workbench.action.git.unstage
workbench.action.gotoLine
workbench.action.gotoSymbol
workbench.action.keepEditor
workbench.action.maximizeEditor
workbench.action.minimizeOtherEditors
workbench.action.moveActiveEditorGroupLeft
workbench.action.moveActiveEditorGroupRight
workbench.action.moveActiveEditorLeft
workbench.action.moveActiveEditorRight
workbench.action.moveEditorLeftInGroup
workbench.action.moveEditorRightInGroup
workbench.action.moveEditorToLeftGroup
workbench.action.moveEditorToRightGroup
workbench.action.navigateBack
workbench.action.navigateEditorGroups
workbench.action.navigateForward
workbench.action.newWindow
workbench.action.nextEditor
workbench.action.openEditorAtIndex1
workbench.action.openEditorAtIndex2
workbench.action.openEditorAtIndex3
workbench.action.openEditorAtIndex4
workbench.action.openEditorAtIndex5
workbench.action.openEditorAtIndex6
workbench.action.openEditorAtIndex7
workbench.action.openEditorAtIndex8
workbench.action.openEditorAtIndex9
workbench.action.openGlobalKeybindings
workbench.action.openGlobalSettings
workbench.action.openLastEditorInGroup
workbench.action.openNextRecentlyUsedEditorInGroup
workbench.action.openPreviousEditor
workbench.action.openPreviousEditorFromHistory
workbench.action.openPreviousRecentlyUsedEditorInGroup
workbench.action.openRecent
workbench.action.openSnippets
workbench.action.openWorkspaceSettings
workbench.action.output.toggleOutput
workbench.action.previousEditor
workbench.action.quickOpen
workbench.action.quickOpenNavigateNext
workbench.action.quickOpenNavigatePrevious
workbench.action.reloadWindow
workbench.action.removeFromEditorHistory
workbench.action.reopenClosedEditor
workbench.action.replaceInFiles
workbench.action.search.toggleQueryDetails
workbench.action.selectIconTheme
workbench.action.selectTheme
workbench.action.showAllEditors
workbench.action.showAllSymbols
workbench.action.showCommands
workbench.action.showEditorsInCenterGroup
workbench.action.showEditorsInLeftGroup
workbench.action.showEditorsInRightGroup
workbench.action.showErrorsWarnings
workbench.action.splitEditor
workbench.action.tasks.build
workbench.action.tasks.configureTaskRunner
workbench.action.tasks.runTask
workbench.action.tasks.showLog
workbench.action.tasks.terminate
workbench.action.tasks.test
workbench.action.terminal.copySelection
workbench.action.terminal.focus
workbench.action.terminal.focusNext
workbench.action.terminal.focusPrevious
workbench.action.terminal.kill
workbench.action.terminal.new
workbench.action.terminal.openNativeConsole
workbench.action.terminal.paste
workbench.action.terminal.runSelectedText
workbench.action.terminal.scrollDown
workbench.action.terminal.scrollUp
workbench.action.terminal.toggleTerminal
workbench.action.toggleDevTools
workbench.action.toggleFullScreen
workbench.action.toggleMenuBar
workbench.action.togglePanel
workbench.action.toggleSidebarPosition
workbench.action.toggleSidebarVisibility
workbench.action.toggleStatusbarVisibility
workbench.action.zoomIn
workbench.action.zoomOut
workbench.action.zoomReset
workbench.actions.view.problems
workbench.debug.action.focusRepl
workbench.debug.action.toggleRepl
workbench.debug.panel.action.clearReplAction
workbench.debug.viewlet.action.addFunctionBreakpointAction
workbench.debug.viewlet.action.disableAllBreakpoints
workbench.debug.viewlet.action.enableAllBreakpoints
workbench.debug.viewlet.action.reapplyBreakpointsAction
workbench.debug.viewlet.action.removeAllBreakpoints
workbench.extensions.action.installExtensions
workbench.extensions.action.listOutdatedExtensions
workbench.extensions.action.showInstalledExtensions
workbench.extensions.action.showPopularExtensions
workbench.extensions.action.showRecommendedExtensions
workbench.files.action.addToWorkingFiles
workbench.files.action.closeAllFiles
workbench.files.action.closeFile
workbench.files.action.closeOtherFiles
workbench.files.action.collapseFilesExplorerFolders
workbench.files.action.compareFileWith
workbench.files.action.focusFilesExplorer
workbench.files.action.focusOpenEditorsView
workbench.files.action.focusWorkingFiles
workbench.files.action.openNextWorkingFile
workbench.files.action.openPreviousWorkingFile
workbench.files.action.refreshFilesExplorer
workbench.files.action.reopenClosedFile
workbench.files.action.showActiveFileInExplorer
workbench.files.action.workingFilesPicker
workbench.output.action.clearOutput
workbench.view.debug
workbench.view.explorer
workbench.view.extensions
workbench.view.git
workbench.view.search
© 2022 - 2024 — McMap. All rights reserved.