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.

8
  • 2
    use console2. sourceforge.net/projects/console
    – Philip
    Oct 21, 2013 at 4:11
  • Do yourself a favour, check out the 'clink' answer on this page. ctrl-v and a whole lot more.
    – bdumtish
    Aug 10, 2015 at 13:15
  • 2
    @pylover fixed in 2015. Aug 28, 2015 at 21:13
  • 1
    @pylover Otherwise for < 10, you can use a clipboard manager. (of course I agree that it's ridiculous cmd doesn't have ctrl+c on < 10) Oct 4, 2015 at 16:55
  • 4
    @pylover Shame on Microsoft, in the year 2016 we must use the mouse to paste into Bash, even though the menu claims that Ctrl+V pastes.
    – Michael
    Dec 29, 2016 at 23:11

21 Answers 21

429

Yes.. but awkward. Link

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

10
  • 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, 2008 at 7: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. May 3, 2009 at 15:40
  • 7
    to complex , i does not have enough fingers to do this job
    – pylover
    Apr 9, 2012 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 6, 2012 at 15:07
  • 2
    For French windows : [Alt] + [Space], [m], [c] for copy, [Alt] + [Space], [m], [o] for paste
    – Deleplace
    Jan 21, 2014 at 16:34
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 
11
  • 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, 2010 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, 2010 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, 2010 at 12:30
  • @piyo: cygwin mintty (no X involved) is so nicer for a cygwin shell... Dec 29, 2010 at 13:27
  • 1
    HowToGeek suggests "SendInput {Raw}%clipboard%" instead of alt-space ep. Then you get rid of the flickering as well Jul 17, 2014 at 16:03
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.
4
  • 14
    we are talking about keyboard shortcuts.
    – pylover
    Apr 9, 2012 at 11:03
  • 11
    Right clicking seems pretty short to me Apr 12, 2013 at 3:51
  • 19
    Moving your hand from the keyboard to the mouse disqualifies it as "pretty short." Feb 24, 2014 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, 2017 at 6: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!

4
  • 2
    good one, improvements are always welcome!
    – PabloG
    May 31, 2010 at 15:15
  • 1
    excellent! the default answer flickered the popup menu, which was annoying Aug 25, 2012 at 18:31
  • thanks, this one gives ctrl-v in console a 'native' feeling
    – jettico
    May 31, 2015 at 11:44
  • When I press ctrl+v it pastes correctly, but also starts executing the string (it's like enter is pressed afterwards). How can I prevent that?
    – LoMaPh
    Feb 24, 2018 at 17:01
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.

1
  • 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 5, 2016 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

3
  • 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, 2016 at 0:00
  • It's weird but it doesn't work even after enabling it in here. Feb 1, 2021 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. May 13, 2022 at 0: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.

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..

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
0
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.

2
  • Yes, right click works fine but that's what I'm trying to avoid.
    – sme
    Sep 25, 2008 at 7: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, 2015 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.

1
  • 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, 2018 at 8: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...

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

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
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 :-)

1

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

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

1
  • 1
    As per the question: instead of using the right mouse button Jun 25, 2012 at 23:21
1

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

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

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!

-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.

1
  • 8
    What part of "instead of using the right mouse button" don't you understand ;)
    – reiniero
    May 30, 2012 at 8:46

Not the answer you're looking for? Browse other questions tagged or ask your own question.