[windows] Keyboard shortcut to paste clipboard content into command prompt window (Win XP)

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.

This question is related to windows keyboard-shortcuts

The answer is


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.


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!


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


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


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

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.


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.

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


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


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


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


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!


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


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.


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


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.


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.


Yes.. but awkward. Link

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


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