10

Git有一个Stage Selected Lines按钮,但是有没有办法为它添加键盘快捷键?

舞台选定线选项

three dots必须单击两次( > )太麻烦了Stage Selected Lines

4

4 回答 4

17

如果有人还在寻找这个:

命令stageSelectedRanges, unstageSelectedRanges,revertSelectedRanges前段时间已经介绍过了。请注意,目前 VSCode 中存在一个相关的错误:差异视图在部分阶段后不会刷新 - 但除此之外它就像一个魅力。

这就是我在我的键绑定中设置它的方式:

{
  "key": "s",
  "command": "git.stageSelectedRanges",
  "when": "isInDiffEditor && editorTextFocus"
},
{
  "key": "u",
  "command": "git.unstageSelectedRanges",
  "when": "isInDiffEditor && editorTextFocus"
},
{
  "key": "r",
  "command": "git.revertSelectedRanges",
  "when": "isInDiffEditor && editorTextFocus"
}
于 2017-09-06T07:13:48.680 回答
8

接受的答案对我不起作用,所以我在 GitHub 上提出了一张票:

当源代码控制视图的条件更好的键绑定 #99683

以下做了:

{
  "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'"
},

更新:

我还能够通过添加listFocus属性来获得单个键:

{
  "key": "s",
  "command": "git.stage",
  "when": "listFocus && sideBarFocus && activeViewlet == 'workbench.view.scm'"
},
于 2020-06-10T18:31:51.790 回答
3

Visual Studio Code 使您能够绑定键盘快捷键以暂存整个文件(workbench.action.git.stage命令)。

据我所知,没有(公开记录的)工作台命令用于暂存选定的行,因此我们没有什么可以绑定键盘快捷键。

于 2016-08-17T01:48:33.233 回答
0

截至 2016 年 10 月,visual-studio-code 的 Default Keyboard Shortcuts 文件包含以下命令(正如@Brynden Bielefeld 提到的,没有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 
于 2016-10-07T09:41:05.700 回答