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

Enh Req: addtional shortcuts to supercharge the CMD line editing experience. #19

Closed
rkeithhill opened this issue Sep 12, 2013 · 7 comments

Comments

@rkeithhill
Copy link
Contributor

I would like to see folks who know how to use the standard CMD keybindings to be able to use the CMD mappings but have access to new bindings thereby giving them an even better line editing experience than CMD. While you could point them at the Emacs mode I think this defeats the goal of an "easy onramp". Here is what I suggest to add to the default CMD set:

Set-PSReadlineKeyHandler -Key Ctrl+Home -BriefDescription BackwardKillLine -Handler { 
    [PSConsoleUtilities.PSConsoleReadLine]::BackwardKillLine()
}
Set-PSReadlineKeyHandler -Key Ctrl+End -BriefDescription KillLine -Handler { 
    [PSConsoleUtilities.PSConsoleReadLine]::KillLine()
}
Set-PSReadlineKeyHandler -Key Ctrl+Delete -BriefDescription KillWord -Handler { 
    [PSConsoleUtilities.PSConsoleReadLine]::KillWord()
}
Set-PSReadlineKeyHandler -Key Ctrl+Shift+Delete -BriefDescription KillBackwardWord -Handler { 
    [PSConsoleUtilities.PSConsoleReadLine]::KillBackwardWord()
}

As for selecting characters to copy to the clipboard, I should be able to use Shift+Left/RightArrow to select a range of text. Shift+Home should select to the beginning of the line. Shift+UpArrow should continue that selection up by one line and Shift+DownArrow should continue that selection down by one line (inverting selection if moving over line that was selected). Then Ctrl+C should copy that to the clipboard, Ctrl+X would cut the text to the clipboard and Delete would just delete the text with no impact to the clipboard (of course, it would go on the undo stack). :-)

Also Ctrl+? (or maybe that is Ctrl+/ so no shift is required to get to the ?) should dump the current key handlers (bindings) in the same way you show possible completions with Ctrl+Space i.e. don't disrupt the current line editing experience. This is for when I forget what the keybinding is for a command.

@rkeithhill
Copy link
Contributor Author

Another thought that would be really slick - paren & curly brace matching via Ctrl+) and Ctrl+}. For extra, extra credit provide double quote and single quote matching - helpful for embedded quote scenarios.

@rkeithhill
Copy link
Contributor Author

And another idea - since PowerShell is so "pipeline" oriented, how about we use PageUp and PageDown (or Ctrl+Shift+Left/RightArrow) to navigate from one pipeline stage to the next place the cursor at the first non-space char after a "|" (except for the first stage when going backwards and the last stage when going forwards)?

@lzybkr
Copy link
Member

lzybkr commented Sep 13, 2013

Great ideas. Maybe you can break these up into different items.

As for mapping Kill commands to cmd mode - I'm not sure that's the best idea. Ctrl+Home/Ctrl+End should probably work the way they do today even after introducing clipboard capabilities. I have something I'll commit soon that works this way.

Just thinking out loud here, but if a delete command took an argument (say via a prefix key) - it could optionally use the clipboard. I introduced an argument to handlers for a numeric count (e.g. as a repeat count), but that argument could be something else, e.g. a bool that says put in the clipboard. Then maybe Ctrl+X,Ctrl+Home would put the deleted text in the clipboard (assuming nothing is selected, if text is selected, then Ctrl+X just cuts that text.)

@rkeithhill
Copy link
Contributor Author

I'm fine with Ctrl+Home & Ctrl+End working the way they do today in CMD (kill to beginning/kill to end). At least that is what I'm observing in cmd.exe. And these two commands do not impact the clipboard which sounds good to me especially if there was an undo/redo feature. :-)

@rkeithhill
Copy link
Contributor Author

I think I've got everything in here split out into separate issues. You can close this one if you like.

@rkeithhill
Copy link
Contributor Author

WRT to your other comment about delete & clipboard capabilities. I think if you could provide common key bindings folks use in Notepad, Word, VS, etc, then folks will find the commands more quickly and be more comfortable with them in terms of knowing what to expect e.g. will this affect the clipboard or not.

@lzybkr
Copy link
Member

lzybkr commented Sep 13, 2013

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants