Welcome to MSDN Blogs Sign in | Join | Help

Ctrl-End it All

Here's a great hint from one of our Windows PowerShell PMs. We all know that you can interrupt a command by typing Ctrl+C, but did you know that you can erase the end of a typed command line by pressing Ctrl+End, just like in Cmd.exe?

 

The Ctrl+End sequence erases all characters at or after the cursor point on the command line.

 

Try it. 

 

  1. Type a command, like:

                        get-itemproperty HKLM:\Software\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell
      
            (Be sure to use tab-completion to save strokes!)

  1. Use the back arrow key  (ß) to place the cursor under the "S" in "ShellIds."

  2. Press Ctrl+End.

    Now you have:

                         get-itemproperty HKLM:\Software\Microsoft\PowerShell\1\

 

            so you can type another useful command, like:

 

                        get-itemproperty HKLM:\Software\Microsoft\PowerShell\1\PowerShellEngine

 

Very handy. And you get it free with Windows PowerShell.

 

June Blender [MSFT]

Senior Programming Writer

Windows PowerShell

Published Tuesday, May 22, 2007 5:35 PM by PowerShellTeam

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# re: Ctrl-End it All

I am sorry but "get it free with Windows PowerShell", I am a long time windows user and this is an old feature of cmd.exe which is the psh running on, the thin is that the command console is not "user friendly" at all!!!

did you see the console2 project in sourceforge?

I don't get it really the power shell is VERY GREAT, but the console is... well you know how the console is, but to go and say "look you can Ctrl+End and it will erase till the end and brag about that???

by the way I am using AutoHotKey to automate a lot of things that the cmd/powershell are not doing like:

#IfWinActive, ahk_class ConsoleWindowClass

!F4::

SendInput ! c

return

^1::

SendInput ! p

Sleep, 100

;WinGetActiveTitle, ttl

;WinMove, , ttl 0, 0

MouseClick, left,  129,  36

Send, {TAB}85{TAB}{TAB}85{TAB}33{ENTER}{ENTER}

DllCall("SetCursorPos", int, 1300, int, -100)

return

^2::

SendInput ! p

Sleep, 100

;WinGetActiveTitle, ttl

;WinMove, , ttl 0, 0

MouseClick, left,  129,  36

Send, {TAB}135{TAB}{TAB}135{TAB}50{ENTER}{ENTER}

DllCall("SetCursorPos", int, 1300, int, -100)

return

^A::

SendInput {Home}

return

^E::

SendInput {End}

return

^U::

send, ^{End}

send, ^{Home}

return

; Paste (Ctrl+V)

^V::

SendInput ! ep

return

; Find dialog (Ctrl+Shift+F)

^+F::

SendInput ! ef

return

; Clear screen (Ctrl+Shift+X)

^+X::

SendInput {Esc}

SendInput cls {ENTER}

return

; Set Scroll

^UP::

^DOWN::

SendInput ! el

return

; Shift+Page up

+PgUp::

SendInput ! el

SendInput {PgUp}

SendInput {Esc}

return

; Shift+Page down

+PgDn::

SendInput ! el

SendInput {PgDn}

SendInput {Esc}

return

#IfWinActive

oh, and yes Ctrl+home work as well :)

Tuesday, May 22, 2007 4:38 PM by John

# re: Ctrl-End it All

We hear you loud and clear on the CONSOLE issue.

Jeffrey Snover [MSFT]

Windows Management Partner Architect

Visit the Windows PowerShell Team blog at:    http://blogs.msdn.com/PowerShell

Visit the Windows PowerShell ScriptCenter at:  http://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx

Tuesday, May 22, 2007 10:27 PM by PowerShellTeam

# re: Ctrl-End it All

My opinion is quite different from anybody. I think that difficult keystrokes is hard to learn, but once learnt, you can't live without. Complex keystrokes is a "good" feature that exists in common *nix shells, like Bash. You can find a lot of examples here:

http://www.faqs.org/docs/bashman/bashref_81.html

I'm not sure but I think I'd already talked with Jeffrey and he explained why this is impossible to do in Powershell (because of cooked-mode and other things). But I still guess is a good thing to change in a future release.

[]s,

--

Vinicius Canto <scripterbr_at_gmail_dot_com>

MVP Visual Developer - Scripting

MCP Windows 2000 Server, Windows XP e SQL Server 2000

Blog sobre Scripting: http://viniciuscanto.blogspot.com

Tuesday, May 22, 2007 11:12 PM by Vinicius Canto [MVP]

# re: Ctrl-End it All

And you can use ctrl+home to delete to the start of the line. Another very good key is F4 that deletes up to the next character you type. I often use it go get rid of the first word in a line I recall - home+f4+space.

You should also try f7 and f8. f7 lists you old commands and f8 search command history starting with what you have written so far.

Thursday, May 24, 2007 7:00 AM by Per Østergaard

# re: Ctrl-End it All

/\/\o\/\/,'s wondering

I'm I the only one that really LOVES the console like it is ?

Greeings /\/\o\/\/

Thursday, May 24, 2007 11:28 AM by /\/\o\/\/

# re: Ctrl-End it All

"We all know that you can interrupt a command by typing Ctrl+C"

Uhm... Am I the only one who, when using "Run As" to get PowerShell to run as an admin, experiences the CTRL+C shortcut NOT working? As in, it won't stop any commands at all?  Only when "running as."  I figured it was a Console bug, but maybe it's a PowerShell bug?  Or maybe my computer is foobared?  heheh.  Can anybody replicate this?  Easy test is Ping -t, since it never ends.

Tuesday, June 05, 2007 3:49 PM by Timothy

# re: Ctrl-End it All

Yes, I have same issue as Timothy.

Tuesday, July 31, 2007 11:03 AM by Jeff

# re: Ctrl-End it All

I also find the ctrl+c annoying.  Of course I'm using runas.  As a sys admin, it's best practice.  Please fix!

Wednesday, August 01, 2007 11:07 AM by Bill

# re: Ctrl-End it All

I have the same problem as Timothy, Jeff and Bill with ctrl+c. Additionally the command buffer doesn't work when using run-as.  Re-typing commands that should be accessable in the buffer is not my idea of a good time! What gives?

Friday, September 07, 2007 2:21 PM by heather

Leave a Comment

(required) 
required 
(required) 
 
Page view tracker