Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support missing keybindings in PowerShell #45705

Closed
Tyriar opened this issue Mar 13, 2018 · 20 comments · Fixed by #154725
Closed

Support missing keybindings in PowerShell #45705

Tyriar opened this issue Mar 13, 2018 · 20 comments · Fixed by #154725
Assignees
Labels
feature-request Request for new features or functionality insiders-released Patch has been released in VS Code Insiders on-testplan terminal General terminal issues that don't fall under another label terminal-shell-integration Shell integration infrastructure, command decorations, etc. terminal-shell-pwsh An issue in the terminal specific to PowerShell, including shell integration
Milestone

Comments

@Tyriar
Copy link
Member

Tyriar commented Mar 13, 2018

Currently various features don't (typically?) work in the prompt on Windows, for example ctrl+backspace to delete a word, ctrl+shift+left to select the word to the left of the prompt etc. We could expose some API in xterm.js to be able to handle this. For example:

Windows:

  • backspace, delete: Press backspace/delete the number of characters that are selected
  • ctrl+backspace: Backspace the number of chars in the preceeding word

All platforms:

  • ctrl+shift+left/right, shift+left/right: Select from the cursor

Perhaps some API like this would be able to handle the selection requests:

// Select from cursor, in the future if we wanted to select from some other origin we
// could add a third parameter
select(direction: 'left' | 'right' | 'up' | 'down', amount: 'word' | 'char'): void;

/cc @sbatten

@Tyriar Tyriar added feature-request Request for new features or functionality terminal General terminal issues that don't fall under another label windows VS Code on Windows issues labels Mar 13, 2018
@Tyriar Tyriar added this to the Backlog milestone Mar 13, 2018
@Tyriar Tyriar self-assigned this Mar 13, 2018
@sbatten
Copy link
Member

sbatten commented Mar 13, 2018

note that there are also differences based on shell in Windows as well. e.g. ctrl+backspace and shift+left do not work as expected on WSL.

@Tyriar
Copy link
Member Author

Tyriar commented Mar 15, 2018

@sbatten not so sure we should do much for different shells, we'd probably need a when clause or something to do it right (which is getting quite complicated).

@sbatten
Copy link
Member

sbatten commented Mar 16, 2018

@Tyriar Fair and agreed. I just want to make sure the changes don't break any experiences in WSL by adding keyboard functionality that didn't exist previously as WSL is something users will expect to work.

@1800Zeta
Copy link

1800Zeta commented May 4, 2018

Upvoting this, I'd like to see the ability to control backspace and delete a word in the terminal on Windows 10 please. Thank you

@WSLUser
Copy link

WSLUser commented May 7, 2018

Is it possible you guys can take advantage of the work the Console team has done via their APIs? You guys are ahead in a few ways than the Console but having features of the Console lacking in the VSCode terminal would be great. Also, for shells, I think you guys have to account for Sets plus whatever shells might be generated from the new APIs being developed by the Console team to allow various terminals to be ported to Windows that are currently only existing in Linux.

@Tyriar
Copy link
Member Author

Tyriar commented May 11, 2018

@DarthSpock I'll be working on that soon 😃

@WSLUser
Copy link

WSLUser commented May 11, 2018

Don't suppose it would be too much to ask if we get ColorTool support in VSCode is it? 😉

@Tyriar
Copy link
Member Author

Tyriar commented May 11, 2018

@DarthSpock I don't think we'll support cmd.exe ColorTool, but themes can set this and you can override the colors like this: https://github.com/Tyriar/vscode-snazzy/blob/b155eb74098971c3daca73942d7d626c8bcc2ec9/snazzy.json#L2-L22

@WSLUser
Copy link

WSLUser commented May 11, 2018

I think the big thing is being able to read the Themes directory. I wouldn't care so much about having the command controls from ColorTool. I just would like the terminal to accept the Iterm2 schemes (in addition to whatever other themes you want). How that happens is up for interpretation. I can see myself sticking purely to the VS Code terminal without ever touching a real console if we had that type of support.

@Tyriar
Copy link
Member Author

Tyriar commented May 11, 2018

@DarthSpock I'd rather not add something like that to core, sounds like a good idea for an extension though to convert .itermcolors files into VS Code settings.

@WSLUser
Copy link

WSLUser commented May 17, 2018

I guess the idea of an extension would work. Considering the support comes from MS, I would request that this would be an offical extension from MS to ensure there aren't any loose bugs and would maintain the proper support as ColorTool adapts. Is there a repo for that type of request or is this one good enough?

@Tyriar
Copy link
Member Author

Tyriar commented May 17, 2018

@DarthSpock well I know that the VS Code team won't have any time to work on that as it affects such a small portion of the users:

  • On windows
  • Wants support for mac-specific application terminal colors format (not the default terminal)
  • Doesn't want to use the already existing solution

This probably is the right repo for such a request but we need to close issues like this in order to keep the issues manageable. This is a good candidate for a community extension.

@WSLUser
Copy link

WSLUser commented May 17, 2018

Sounds fair.

@f-roche
Copy link

f-roche commented Jun 28, 2019

Hi @Tyriar, is there any update regarding this issue (typically ctrl+backspace to delete a word)? or any extension that would fix it?
Thanks

@Tyriar
Copy link
Member Author

Tyriar commented Jun 28, 2019

@f-roche you could try using Set-PSReadLineOption -EditMode Emacs in PowerShell, that might work.

@Tyriar
Copy link
Member Author

Tyriar commented Oct 8, 2019

Some of this works now with the emacs edit mode, you can also configure your own keybindings. Going to close this issue off as it's pretty general, please open focused issues if you cannot configure your own PSReadLine options for this.

Note that you can enable escape sequence logging in Insiders which can tell you what character codes are sent when you type: https://github.com/microsoft/vscode/wiki/Terminal-Issues#enabling-escape-sequence-logging

@Tyriar Tyriar added the *out-of-scope Posted issue is not in scope of VS Code label Oct 8, 2019
@vscodebot
Copy link

vscodebot bot commented Oct 8, 2019

This issue is being closed to keep the number of issues in our inbox on a manageable level, we are closing issues that are not going to be addressed in the foreseeable future: We look at the number of votes the issue has received and the number of duplicate issues filed. More details here. If you disagree and feel that this issue is crucial: We are happy to listen and to reconsider.

If you wonder what we are up to, please see our roadmap and issue reporting guidelines.

Thanks for your understanding and happy coding!

@vscodebot vscodebot bot closed this as completed Oct 8, 2019
@Tyriar Tyriar added terminal-shell-integration Shell integration infrastructure, command decorations, etc. terminal-shell-pwsh An issue in the terminal specific to PowerShell, including shell integration and removed windows VS Code on Windows issues *out-of-scope Posted issue is not in scope of VS Code labels Jul 4, 2022
@Tyriar Tyriar removed this from the Backlog milestone Jul 4, 2022
@Tyriar Tyriar added this to the July 2022 milestone Jul 4, 2022
@Tyriar
Copy link
Member Author

Tyriar commented Jul 4, 2022

Looks like this will now be possible to do when shell integration is enabled using this technique 🎉. Ctrl+space on macOS/pwsh 7:

Screen Shot 2022-07-04 at 6 31 43 am

@Tyriar Tyriar reopened this Jul 4, 2022
@Tyriar Tyriar changed the title Improve terminal prompt experience on Windows Support missing keybindings in PowerShell Jul 4, 2022
Tyriar added a commit that referenced this issue Jul 10, 2022
@Tyriar
Copy link
Member Author

Tyriar commented Jul 10, 2022

Default keybindings on macOS:

Basic editing functions
=======================

Key              Function              Description
---              --------              -----------
Ctrl+g           Abort                 Abort the current operation, e.g. incremental history search
Ctrl+o           AcceptAndGetNext      Accept the current line and recall the next line from history after the current line finishes executing
Enter            AcceptLine            Accept the input or move to the next line if input is missing a closing token.
Shift+Enter      AddLine               Move the cursor to the next line without attempting to execute the input
Backspace        BackwardDeleteChar    Delete the character before the cursor
Ctrl+Backspace   BackwardDeleteChar    Delete the character before the cursor
Ctrl+u           BackwardKillLine      Move the text from the cursor to the beginning of the line to the kill ring
Ctrl+x,Backspace BackwardKillLine      Move the text from the cursor to the beginning of the line to the kill ring
Alt+Backspace    BackwardKillWord      Move the text from the start of the current or previous word to the cursor to the kill ring
Escape,Backspace BackwardKillWord      Move the text from the start of the current or previous word to the cursor to the kill ring
Ctrl+c           CopyOrCancelLine      Either copy selected text to the clipboard, or if no text is selected, cancel editing the line with
                                       CancelLine.
Delete           DeleteChar            Delete the character under the cursor
Ctrl+d           DeleteCharOrExit      Delete the character under the cursor, or if the line is empty, exit the process.
Ctrl+k           KillLine              Move the text from the cursor to the end of the input to the kill ring
Alt+d            KillWord              Move the text from the cursor to the end of the current or next word to the kill ring
Escape,d         KillWord              Move the text from the cursor to the end of the current or next word to the kill ring
Alt+r            RevertLine            Equivalent to undo all edits (clears the line except lines imported from history)
Escape,r         RevertLine            Equivalent to undo all edits (clears the line except lines imported from history)
Ctrl+t           SwapCharacters        Swap the current character with the character before it.
Ctrl+_           Undo                  Undo a previous edit
Ctrl+x,Ctrl+u    Undo                  Undo a previous edit
Ctrl+w           UnixWordRubout        Move the text from the cursor to the start of the current or previous whitespace delimited word to the
                                       kill ring
Ctrl+m           ValidateAndAcceptLine Accept the input or move to the next line if input is missing a closing token.
                                       If there are other parse errors, unresolved commands, or incorrect parameters, show the error and
                                       continue editing.
Ctrl+y           Yank                  Copy the text from the current kill ring position to the input
Alt+.            YankLastArg           Copy the text of the last argument to the input
Alt+_            YankLastArg           Copy the text of the last argument to the input
Escape,.         YankLastArg           Copy the text of the last argument to the input
Escape,_         YankLastArg           Copy the text of the last argument to the input
Ctrl+Alt+y       YankNthArg            Copy the text of the first argument to the input
Escape,Ctrl+y    YankNthArg            Copy the text of the first argument to the input
Alt+y            YankPop               Replace the previously yanked text with the text from the next kill ring position
Escape,y         YankPop               Replace the previously yanked text with the text from the next kill ring position

Cursor movement functions
=========================

Key        Function        Description
---        --------        -----------
LeftArrow  BackwardChar    Move the cursor back one character
Ctrl+b     BackwardChar    Move the cursor back one character
Alt+b      BackwardWord    Move the cursor to the beginning of the current or previous word
Escape,b   BackwardWord    Move the cursor to the beginning of the current or previous word
Home       BeginningOfLine Move the cursor to the beginning of the line
Ctrl+a     BeginningOfLine Move the cursor to the beginning of the line
End        EndOfLine       Move the cursor to the end of the line
Ctrl+e     EndOfLine       Move the cursor to the end of the line
RightArrow ForwardChar     Move the cursor forward one character
Ctrl+f     ForwardChar     Move the cursor forward one character
Alt+f      ForwardWord     Move the cursor forward to the end of the current word, or if between words, to the end of the next word. 
Escape,f   ForwardWord     Move the cursor forward to the end of the current word, or if between words, to the end of the next word. 

History functions
=================

Key       Function             Description
---       --------             -----------
Alt+<     BeginningOfHistory   Move to the first item in the history
Alt+>     EndOfHistory         Move to the last item (the current input) in the history
Ctrl+s    ForwardSearchHistory Search history forward interactively
DownArrow NextHistory          Replace the input with the next item in the history
Ctrl+n    NextHistory          Replace the input with the next item in the history
UpArrow   PreviousHistory      Replace the input with the previous item in the history
Ctrl+p    PreviousHistory      Replace the input with the previous item in the history
Ctrl+r    ReverseSearchHistory Search history backwards interactively

Completion functions
====================

Key   Function            Description
---   --------            -----------
Tab   Complete            Complete the input if there is a single completion, otherwise complete the input with common prefix for all
                          completions.  Show possible completions if pressed a second time.
Alt+= PossibleCompletions Display the possible completions without changing the input

Miscellaneous functions
=======================

Key           Function        Description
---           --------        -----------
Ctrl+l        ClearScreen     Clear the screen and redraw the current line at the top of the screen
Alt+0         DigitArgument   Start or accumulate a numeric argument to other functions
Alt+1         DigitArgument   Start or accumulate a numeric argument to other functions
Alt+2         DigitArgument   Start or accumulate a numeric argument to other functions
Alt+3         DigitArgument   Start or accumulate a numeric argument to other functions
Alt+4         DigitArgument   Start or accumulate a numeric argument to other functions
Alt+5         DigitArgument   Start or accumulate a numeric argument to other functions
Alt+6         DigitArgument   Start or accumulate a numeric argument to other functions
Alt+7         DigitArgument   Start or accumulate a numeric argument to other functions
Alt+8         DigitArgument   Start or accumulate a numeric argument to other functions
Alt+9         DigitArgument   Start or accumulate a numeric argument to other functions
Alt+-         DigitArgument   Start or accumulate a numeric argument to other functions
Ctrl+Alt+?    ShowKeyBindings Show all key bindings
Ctrl+x,Ctrl+e ViEditVisually  Invokes the console compatible editor specified by $env:VISUAL or $env:$EDITOR on the current command line.
Alt+?         WhatIsKey       Show the key binding for the next chord entered

Selection functions
===================

Key              Function             Description
---              --------             -----------
Ctrl+x,Ctrl+x    ExchangePointAndMark Mark the location of the cursor and move the cursor to the position of the previous mark
Shift+LeftArrow  SelectBackwardChar   Adjust the current selection to include the previous character
Shift+Home       SelectBackwardsLine  Adjust the current selection to include from the cursor to the start of the line
Alt+B            SelectBackwardWord   Adjust the current selection to include the previous word
Shift+RightArrow SelectForwardChar    Adjust the current selection to include the next character
Alt+F            SelectForwardWord    Adjust the current selection to include the next word using ForwardWord
Shift+End        SelectLine           Adjust the current selection to include from the cursor to the end of the line
Ctrl+@           SetMark              Mark the location of the cursor
Alt+Spacebar     SetMark              Mark the location of the cursor

Search functions
================

Key        Function                Description
---        --------                -----------
Ctrl+]     CharacterSearch         Read a character and move the cursor to the next occurence of that character
Ctrl+Alt+] CharacterSearchBackward Read a character and move the cursor to the previous occurence of that character

@Tyriar
Copy link
Member Author

Tyriar commented Jul 11, 2022

Windows default keybindings:

Basic editing functions
=======================

Key              Function           Description
---              --------           -----------
Enter            AcceptLine         Accept the input or move to the next line if input is missing a closing token.
Shift+Enter      AddLine            Move the cursor to the next line without attempting to execute the input
Backspace        BackwardDeleteChar Delete the character before the cursor
Ctrl+h           BackwardDeleteChar Delete the character before the cursor
Ctrl+Home        BackwardDeleteLine Delete text from the cursor to the start of the line
Ctrl+Backspace   BackwardKillWord   Move the text from the start of the current or previous word to the cursor to the
                                    kill ring
Ctrl+w           BackwardKillWord   Move the text from the start of the current or previous word to the cursor to the
                                    kill ring
Ctrl+C           Copy               Copy selected region to the system clipboard.  If no region is selected, copy the
                                    whole line
Ctrl+c           CopyOrCancelLine   Either copy selected text to the clipboard, or if no text is selected, cancel
                                    editing the line with CancelLine.
Ctrl+x           Cut                Delete selected region placing deleted text in the system clipboard
Delete           DeleteChar         Delete the character under the cursor
Ctrl+End         ForwardDeleteLine  Delete text from the cursor to the end of the line
Ctrl+Enter       InsertLineAbove    Inserts a new empty line above the current line without attempting to execute the     
                                    input
Shift+Ctrl+Enter InsertLineBelow    Inserts a new empty line below the current line without attempting to execute the     
                                    input
Alt+d            KillWord           Move the text from the cursor to the end of the current or next word to the kill ring 
Ctrl+Delete      KillWord           Move the text from the cursor to the end of the current or next word to the kill ring 
Ctrl+v           Paste              Paste text from the system clipboard
Shift+Insert     Paste              Paste text from the system clipboard
Ctrl+y           Redo               Redo an undo
Escape           RevertLine         Equivalent to undo all edits (clears the line except lines imported from history)     
Ctrl+z           Undo               Undo a previous edit
Alt+.            YankLastArg        Copy the text of the last argument to the input

Cursor movement functions
=========================

Key             Function        Description
---             --------        -----------
LeftArrow       BackwardChar    Move the cursor back one character
Ctrl+LeftArrow  BackwardWord    Move the cursor to the beginning of the current or previous word
Home            BeginningOfLine Move the cursor to the beginning of the line
End             EndOfLine       Move the cursor to the end of the line
RightArrow      ForwardChar     Move the cursor forward one character
Ctrl+]          GotoBrace       Go to matching brace
Ctrl+RightArrow NextWord        Move the cursor forward to the start of the next word

History functions
=================

Key       Function              Description
---       --------              -----------
Alt+F7    ClearHistory          Remove all items from the command line history (not PowerShell history)
Ctrl+s    ForwardSearchHistory  Search history forward interactively
F8        HistorySearchBackward Search for the previous item in the history that starts with the current input - like     
                                PreviousHistory if the input is empty
Shift+F8  HistorySearchForward  Search for the next item in the history that starts with the current input - like
                                NextHistory if the input is empty
DownArrow NextHistory           Replace the input with the next item in the history
UpArrow   PreviousHistory       Replace the input with the previous item in the history
Ctrl+r    ReverseSearchHistory  Search history backwards interactively

Completion functions
====================

Key           Function            Description
---           --------            -----------
Tab           Complete            Complete the input if there is a single completion, otherwise complete the input with   
                                  common prefix for all completions.  Show possible completions if pressed a second time. 
Ctrl+@        MenuComplete        Complete the input if there is a single completion, otherwise complete the input by     
                                  selecting from a menu of possible completions.
Ctrl+Spacebar MenuComplete        Complete the input if there is a single completion, otherwise complete the input by     
                                  selecting from a menu of possible completions.
Shift+Tab     TabCompletePrevious Complete the input using the previous completion

Miscellaneous functions
=======================

Key           Function              Description
---           --------              -----------
Ctrl+l        ClearScreen           Clear the screen and redraw the current line at the top of the screen
Alt+0         DigitArgument         Start or accumulate a numeric argument to other functions
Alt+1         DigitArgument         Start or accumulate a numeric argument to other functions
Alt+2         DigitArgument         Start or accumulate a numeric argument to other functions
Alt+3         DigitArgument         Start or accumulate a numeric argument to other functions
Alt+4         DigitArgument         Start or accumulate a numeric argument to other functions
Alt+5         DigitArgument         Start or accumulate a numeric argument to other functions
Alt+6         DigitArgument         Start or accumulate a numeric argument to other functions
Alt+7         DigitArgument         Start or accumulate a numeric argument to other functions
Alt+8         DigitArgument         Start or accumulate a numeric argument to other functions
Alt+9         DigitArgument         Start or accumulate a numeric argument to other functions
Alt+-         DigitArgument         Start or accumulate a numeric argument to other functions
PageDown      ScrollDisplayDown     Scroll the display down one screen
Ctrl+PageDown ScrollDisplayDownLine Scroll the display down one line
PageUp        ScrollDisplayUp       Scroll the display up one screen
Ctrl+PageUp   ScrollDisplayUpLine   Scroll the display up one line
Ctrl+Alt+?    ShowKeyBindings       Show all key bindings
Alt+?         WhatIsKey             Show the key binding for the next chord entered

Selection functions
===================

Key                   Function            Description
---                   --------            -----------
Ctrl+a                SelectAll           Select the entire line. Moves the cursor to the end of the line
Shift+LeftArrow       SelectBackwardChar  Adjust the current selection to include the previous character
Shift+Home            SelectBackwardsLine Adjust the current selection to include from the cursor to the start of the     
                                          line
Shift+Ctrl+LeftArrow  SelectBackwardWord  Adjust the current selection to include the previous word
Shift+RightArrow      SelectForwardChar   Adjust the current selection to include the next character
Shift+End             SelectLine          Adjust the current selection to include from the cursor to the end of the line  
Shift+Ctrl+RightArrow SelectNextWord      Adjust the current selection to include the next word

Search functions
================

Key      Function                Description
---      --------                -----------
F3       CharacterSearch         Read a character and move the cursor to the next occurence of that character
Shift+F3 CharacterSearchBackward Read a character and move the cursor to the previous occurence of that character

@vscodenpa vscodenpa added unreleased Patch has not yet been released in VS Code Insiders insiders-released Patch has been released in VS Code Insiders and removed unreleased Patch has not yet been released in VS Code Insiders labels Jul 11, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Aug 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality insiders-released Patch has been released in VS Code Insiders on-testplan terminal General terminal issues that don't fall under another label terminal-shell-integration Shell integration infrastructure, command decorations, etc. terminal-shell-pwsh An issue in the terminal specific to PowerShell, including shell integration
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants