305

Is there a keyboard shortcut for pasting the content of the clipboard into a command prompt window on Windows XP (instead of using the right mouse button)?

The typical Shift+Insert does not seem to work here.

Abin Manathoor Devasia
  • 1,945
  • 2
  • 21
  • 47
sme
  • 5,673
  • 7
  • 32
  • 30

21 Answers21

429

Yes.. but awkward. Link

alt + Space, e, k <-- for copy and
alt + Space, e, p <-- for paste.

Callum Watkins
  • 2,844
  • 4
  • 29
  • 49
Nescio
  • 27,645
  • 10
  • 53
  • 72
  • 18
    Not exactly what I hoped for, but of course it works. Some additional tips: If you've mapped ALT+SPACE to your application launcher (e.g. Launchy) use ALT-SHIFT-SPACE instead If you're using a non-englisch version of windows the last 2 keys will of course differ (e.g. B+E for paste in german) – sme Sep 25 '08 at 07:54
  • 4
    Just to explain selecting also: ALT+SPACE+E+K <-- for copy . and navigate up , down , left , right with arrows Shift + right arrow <-- for selecting the text ALT+SPACE+E+P <-- for paste. – Yordan Georgiev May 03 '09 at 15:40
  • 7
    to complex , i does not have enough fingers to do this job – pylover Apr 09 '12 at 11:01
  • 5
    I find this answer the most useful and straight to the point. The key sequence doesn't shock me, as there are Emacs chord sequences quite worse than this. Actually, the window menu shortcut Alt+Space is enough to understand what to press next, since there's visual feedback (underlined characters). – acelent Sep 06 '12 at 15:07
  • 2
    For French windows : [Alt] + [Space], [m], [c] for copy, [Alt] + [Space], [m], [o] for paste – Deleplace Jan 21 '14 at 16:34
  • doesn't work for a virtualbox windows VM on linux host – bph May 07 '15 at 10:13
  • Hotkeys differ between localized versions. And will not work in a wrong keyboard layout. So, it is not an universal trick. – Dmitry Ilukhin Apr 27 '16 at 12:12
  • For Germans: ALT+SPACE+B+E for pasting, ALT-SPACE+B+K for copying. – J Fabian Meier Jun 23 '16 at 14:45
  • Nah... after 8 years... XP is dead... On Windows 7, the "Paste" command is grayed out on the command line... back to the starting point... – AlexD Jun 23 '16 at 15:53
  • for copy shoudln't it have e,y. y is underlined in my Copy command – Sreeraj Chundayil Mar 22 '17 at 08:39
163

I personally use a little AutoHotkey script to remap certain keyboard functions, for the console window (CMD) I use:

; Redefine only when the active window is a console window 
#IfWinActive ahk_class ConsoleWindowClass

; Close Command Window with Ctrl+w
$^w::
WinGetTitle sTitle
If (InStr(sTitle, "-")=0) { 
    Send EXIT{Enter}
} else {
    Send ^w
}

return 


; Ctrl+up / Down to scroll command window back and forward
^Up::
Send {WheelUp}
return

^Down::
Send {WheelDown}
return


; Paste in command window
^V::
; Spanish menu (Editar->Pegar, I suppose English version is the same, Edit->Paste)
Send !{Space}ep
return

#IfWinActive 
PabloG
  • 25,761
  • 10
  • 46
  • 59
  • This stuff interferes with Cygwin when it is running inside a ConsoleWindow. I was excited about this tip but unfortunately I had to uninstall it. – piyo Aug 24 '10 at 13:26
  • 2
    @piyo: maybe you can exclude the Cygwin console by its titlebar? eg: if the console title bar says "ConsoleWindow" you can add something like WinGetTitle sTitle\n If (sTitle="ConsoleWindow") {\n return\n }\n --- – PabloG Aug 24 '10 at 15:21
  • Good idea. (+1) Yeah that would work if the window titles are unchanging. I feel like I have more control over the window title in Cygwin so perhaps I can add some static yet invisible hinting text for AHK's filtering. – piyo Aug 26 '10 at 12:30
  • @piyo: cygwin mintty (no X involved) is so nicer for a cygwin shell... – Paulo Scardine Dec 29 '10 at 13:27
  • I also added the line regarding copy&pasting but with Insert:: at the beginning to be more compliant with mintty. – born Feb 11 '13 at 12:04
  • IF you use alt space for something else (IE Launchy) Try changing "Send !{Space}ep" to "Send !+{Space}ep" (Alt Shift space opens the menu as well) – Forge May 31 '13 at 19:25
  • Just FYI if you use `#IfWinActive C:\windows\system32\cmd.exe` instead of `#IfWinActive ahk_class ConsoleWindowClass` then the script _should_ only apply to the Windows console, and not all consolos (not Cygwin). – Scott Marchant Jun 04 '13 at 23:27
  • Can selecting text be also done? Shift+ arrow keys ? – bad_keypoints Oct 14 '13 at 10:03
  • 1
    HowToGeek suggests "SendInput {Raw}%clipboard%" instead of alt-space ep. Then you get rid of the flickering as well – Vegar Westerlund Jul 17 '14 at 16:03
  • @VegarWesterlund With that solution you get issues if you use more than one keyboard layout, similar to this issue: http://stackoverflow.com/questions/15882714/autohotkey-wrong-keystrokes-sent-to-console – CrouZ Aug 14 '15 at 15:36
  • I just couldn't figure out how to invoke the context menu from the keyboard, I tried AppsKey and Alt, but nothing was working, and I had no idea about this alt+space combination! You saved me lots of time. Thanks man! – Isti115 Nov 20 '15 at 22:53
137

Not really programming related, but I found this on Google, there is not a direct keyboard shortcut, but makes it a little quicker.

To enable or disable QuickEdit mode:

  1. Open the MS-DOS program, or the command prompt.
  2. Right-click the title bar and press Properties.
  3. Select the Options tab.
  4. Check or un-check the QuickEdit Mode box.
  5. Press OK.
  6. In the Apply Properties To Shortcut dialog, select the Apply properties to current window only if you wish to change the QuickEdit setting for this session of this window only, or select Modify shortcut that started this window to change the QuickEdit setting for all future invocations of the command prompt, or MS-DOS program.

QuickEdit

To Copy text when QuickEdit is enabled:

  1. Click and drag the mouse pointer over the text you want.
  2. Press Enter (or right-click anywhere in the window) to copy the text to the clipboard.

To Paste text when QuickEdit is enabled:

  1. Right-click anywhere in the window.

To Copy text when QuickEdit is disabled:

  1. Right-click the title bar, press Edit on the menu, and press Mark.
  2. Drag the mouse over the text you want to copy.
  3. Press Enter (or right-click anywhere in the window) to copy the text to the clipboard.

To Paste text when QuickEdit is disabled:

  1. Right-click the title bar, press Edit on the menu, and press Paste.
Community
  • 1
  • 1
Rob Cooper
  • 28,567
  • 26
  • 103
  • 142
  • 14
    we are talking about keyboard shortcuts. – pylover Apr 09 '12 at 11:03
  • 11
    Right clicking seems pretty short to me – Jay Sullivan Apr 12 '13 at 03:51
  • 19
    Moving your hand from the keyboard to the mouse disqualifies it as "pretty short." – Ross Presser Feb 24 '14 at 17:54
  • Hey, that's cool. Here is how I use it: I have created a shortcut on my desktop to cmd.exe then right-clicked on it to "Pin to taskbar" - then delete the shortcut from the desktop... then I right click on it in the task bat, then right-click again when it shows cmd, and pick Properties. I go into Advanced then tell it to run as Administrator. Then OK back and pick the options tab and enable QuickEdit just like you describe here. And Voila, this is then ALWAYS enabled for the paste to be done by right-click at the prompt whenever I use the black CMD icon in the task bar. – SDsolar Nov 23 '17 at 06:10
34

Thanks Pablo, just what I was looking for! However, if I can take the liberty of improving your script slightly, I suggest replacing your ^V macro with the following:

; Use backslash instead of backtick (yes, I am a C++ programmer).
#EscapeChar \

; Paste in command window.
^V::
StringReplace clipboard2, clipboard, \r\n, \n, All
SendInput {Raw}%clipboard2%
return

The advantage of using SendInput is that

  • it doesn't rely on the command prompt system menu having an "Alt+Space E P" menu item to do the pasting (works for English and Spanish, but not for all languages).
  • it avoids that nasty flicker you get as the menu is created and destroyed.

Note, it's important to include the "{Raw}" in the SendInput command, in case the clipboard happens to contain "!", "+", "^" or "#".

Note, it uses StringReplace to remove excess Windows carriage return characters. Thanks hugov for that suggestion!

Ahmed Kotb
  • 6,269
  • 6
  • 33
  • 52
Huw Walters
  • 1,888
  • 20
  • 20
18

There is also a great open source tool called clink, which extends cmd by many features. One of them is being able to use ctrl+v to insert text.

sibbl
  • 3,203
  • 26
  • 38
  • Most of the features of clink are great, but it breaks one useful feature IMO. cmd.exe's autocompletion cycles through files. clink's displays a list when multiple files begin with the same name. For long filenames that begin with the same name, cmd.exe has a better autocompletion. – ChaimG Jul 05 '16 at 16:09
16

On Windows 10, you can enable Ctrl + C and Ctrl + V to work in the command prompt:

enter image description here

enter image description here

Franck Dernoncourt
  • 77,520
  • 72
  • 342
  • 501
  • 2
    They moved this setting to the options-tab and enabled it by default, therefore the experimental does not exist anymore (everything seems to be inside the options-tab, just the opactiy setting is in the colors-tab).So it should just work now :) – CptObvious Mar 27 '16 at 00:00
  • It's weird but it doesn't work even after enabling it in here. – Mahdi Ghajary Feb 01 '21 at 13:16
  • In my windows, there is a direct option in properties-- Use ctrl+shift+c/v as copy/paste. Check this option and it works exactly like the linux terminal. – Adwait Mathkari May 13 '22 at 00:04
8

Here's a free tool that will do it on Windows. I prefer it to a script as it's easy to set up. It runs as a fast native app, works on XP and up, has configuration settings that allow to remap copy/paste/selection keys for command windows:

enter image description here

Plus I know the developers.

c00000fd
  • 20,994
  • 29
  • 177
  • 400
4

Thanks, Pablo, for referring to AutoHotkey utility. Since I have Launchy installed which uses Alt+Space I had to modify it a but to add Shift key as shown:

; Paste in command window
^V::
; Spanish menu (Editar->Pegar, I suppose English version is the same, Edit->Paste)
Send !+{Space}ep
return
Mwiza
  • 7,780
  • 3
  • 46
  • 42
Maksym Kozlenko
  • 10,273
  • 2
  • 66
  • 55
4

simplest method is just the copy the text that you want to paste it in cmd and open cmd goto "properties"---> "option" tab----> check the (give tick mark) "quickEdit mode" and click "ok" .....now you can paste any text from clipboard by doing right click from ur mouse.

Thank you..

Vignesh VRT
  • 399
  • 3
  • 15
3

This is not really a shortcut but just a quick access to the control menu: Alt-space E P

If you can use your mouse, right click on the cmd window works as paste when I tried it.

jop
  • 82,837
  • 10
  • 55
  • 52
  • Yes, right click works fine but that's what I'm trying to avoid. – sme Sep 25 '08 at 07:41
  • Turns out four keystrokes beats moving the hand to the mouse. This solution also wins because it's ready to go on any machine. – Nick Sep 15 '15 at 10:39
3

Theoretically, the application in DOS Prompt has its own clipboard and shortcuts. To import text from Windows clipboard is "extra". However you can use Alt-Space to open system menu of Prompt window, then press E, P to select Edit, Paste menu. However, MS could provide shortcut using Win-key. There is no chance to be used in DOS application.

i486
  • 6,491
  • 4
  • 24
  • 41
  • 1
    Just as a side note: When you see the cmd through an RDP connection, it's Alt-Del instead of Alt-Space. – Bowi Mar 26 '18 at 08:44
2

It took me a small while to figure out why your AutoHotkey script does not work with me:

; Use backslash instead of backtick (yes, I am a C++ programmer).
#EscapeChar \

; Paste in command window.
^V::
StringReplace clipboard2, clipboard, \r\n, \n, All
SendInput {Raw}%clipboard2%
return

In fact, it relies on keystrokes and consequently on keyboard layout! So when you are, as I am, unfortunate to have only an AZERTY keyboard, your suggestion just does not work. And worse, I found no easy way to replace SendInput method or twist its environment to fix this. For example SendInput "1" just does not send digit 1.

I had to turn every character into its unicode to make it work on my computer:

#EscapeChar \

; Paste in command window.
^V::
StringReplace clipboard2, clipboard, \r\n, \n, All
clipboard3 := ""
Loop {
    if (a_index>strlen(clipboard2))
     break 
    char_asc := Asc(SubStr(clipboard2, a_Index, 1))   
    if (char_asc > 127 and char_asc < 256)
     add_zero := "0"
    else
     add_zero := "" 
    clipboard3 :=  clipboard3  . "{Asc " .  add_zero . char_asc . "}"
}
SendInput %clipboard3%
return

Not very simple...

Djee
  • 429
  • 3
  • 9
2

I followed @PabloG's steps as follows

  1. goto http://www.autohotkey.com/ - download autohotkey
  2. follow simple installation steps
  3. after installation create new *.ahk file as follows right click on desktop > new > Autohotkey Script > giveAnyFileName.ahk
  4. right click on this file > Edit
  5. copy paste autohotkey script given by @PabloG in his answer
  6. save and close
  7. double click on file to run
  8. Done now you should be able to use Ctrl+v for paste in command prompt
Mwiza
  • 7,780
  • 3
  • 46
  • 42
Pravin W
  • 2,451
  • 1
  • 20
  • 26
2

If you use the clipboard manager Ditto (open source, gratis), you can simply use the shortcut to paste from Ditto, and it will paste the clipboard in CMD for you.

enter image description here

Franck Dernoncourt
  • 77,520
  • 72
  • 342
  • 501
1

You could try using Texter and create something unlikely like:

./p , triggered by space and replacing the text with %c

I just tested it and it works fine. The only gotcha is to use a rare sequence, as Texter cannot restrict this to just cmd.

There are probably other utilities of this kind which could work, and even AutoHotKey, upon which Texter is built could do it better, but Texter is easy :-)

njsf
  • 2,729
  • 1
  • 21
  • 17
1

Pretty simple solution may be Console 2, redefine keys and you go.

Bruno
  • 6,623
  • 5
  • 41
  • 47
1

A simpler way is to use windows powershell instead of cmd. itworks fine with texter.

ilcredo
  • 785
  • 2
  • 7
  • 17
1

If you're a Cygwin user, you can append the following to your ~/.bashrc file:

stty lnext ^q stop undef start undef

And the following to your ~/.inputrc file:

"\C-v": paste-from-clipboard
"\C-C": copy-to-clipboard

Restart your Cygwin terminal.

(Note, I've used an uppercase C for copy, since CTRL+c is assigned to the break function on most consoles. Season to taste.)

Source

U007D
  • 5,772
  • 2
  • 38
  • 44
1

Instead of "right click"....start your session (once you're in the command prompt window) by keying Alt/SpaceBar. That will open the Command Prompt window menu and you'll see your familiar, underlined keyboard command shortcuts, just like in Windows GUI.

Good luck!

1

I've recently found that command prompt has support for context menu via the right mouse click. You can find more details here: http://www.askdavetaylor.com/copy_paste_within_microsoft_windows_command_prompt.html

Denis Vuyka
  • 2,805
  • 1
  • 17
  • 10
-4

Under VISTA Command prompt: Click on the System Icon Select Defaults from the Menu On the Options tab in the Options group I have "Quick Edit Mode", "Insert Mode", and "Auto Complete" selected I think that "Quick Edit Mode" is what makes it work.

To paste whatever is in the Clipboard at the insertion point: Right Click. To copy from the Command Window Select by holding down the left mouse button and dragging the pointer across what you want to copy Once selected, right click To paste at the insertion point, right click again.