I know how to
open
a command prompt in Microsoft Windows, but the normal methods
for cutting and copying and pasting — like Ctrl-C and Ctrl-V — don’t seem to work
inside a command prompt window. How can I do copying and pasting with a command prompt?
It’s possible to copy and paste within a Microsoft Windows command prompt, and to copy and
paste text to/from other programs, but the commands and keyboard keys to do so are different
from most other Windows programs.
Pressing Ctrl-C and Ctrl-V do not work, and selecting
text within a command prompt to copy, requires a few more steps.
To paste text within a command prompt that has been copied from another program, is the
easiest. Simply copy the text from the other program, then right-click inside the
command prompt window and pick “Paste”:
To copy text from a command prompt is a bit more awkward. As you know from using
Microsoft Word and many other programs, when you select text on the screen, the selection
runs from the first word you selected, to the last word:
Inside a command prompt, on the other hand, the “selected” text doesn’t run from the first
selected word, in straight lines from left to right across the command prompt window, to
the last selected word. Instead, you can only select text within a command prompt that
lies inside a perfect rectangle!
For example, suppose you were trying to type “ipconfig” inside a command prompt, and you
accidentally typed “ioconfig” and got this error message:
You want to copy this error message and e-mail it to your friend to ask them what
went wrong.
To select text within the command prompt window, first right-click anywhere inside the
command prompt and pick “Mark”:
Then, to select text, you left-click inside the command prompt window, and drag the mouse
pointer to create a rectangle outlining the text that you want to copy:
And then to actually copy the selected text, hit the Enter key. Observe that in
this case, the selection really did only include the text inside the rectangle, rather than
running to the end of the line, back to the beginning of the next line and so on. So if you
paste the selected text into another program, it really will only paste the text that was
included in the rectangle:
(It’s a bit difficult to explain why text selection works this way in a command prompt,
but it has to do with the history of the command prompt interface, which goes all the way
back to DOS, the forerunner of Microsoft Windows from the 1980s. Essentially, the command
prompt interface only “knows” that its output consists
of a pattern of characters that are displayed in certain
fixed positions on the screen, in a grid that happens to be exactly 80 characters wide
and 45 lines high. These characters could be text, or graphics from a primitive computer
game that displayed graphics by filling the screen with letters in a certain pattern —
the command prompt doesn’t “know” that the
characters consist of text, and that the user wants to select a block of text that runs
to the end of the line, then starts at the beginning of the next line, and so on. Just
realize that Microsoft didn’t design the command prompt interface this way just to screw
with you.)
So to copy the entire text of the error, you have to click and drag a rectangle around the entire
text that you want to select:
and then hit Enter to copy the text to your clipboard. Then you can paste it in an e-mail
message to your friend.
Bennett Haselton is a technology and political blogger who writes guest articles
for AskDaveTaylor, but his real passion lies elsewhere, like telling people
how to bypass 8e6 filtering software.