Terminal: How do I copy/paste in WSL terminal?

Created on 23 Jun 2019  Â·  25Comments  Â·  Source: microsoft/terminal

In Powershell, I noticed that ctrl+shift+v pastes the contents of the clipboard. ctrl+shift+c does not copy anything, it just falls back to ctrl+c which is mapped to esc.

In my Ubuntu terminal, however, ctrl+shift+v does not paste. It seems the only way to copy/paste is to use right-click. Is there a way to add custom keybindings to copy/paste?

Poking around the source code I found CopyText and PasteText shortcuts:

image

However, when I tried to add them to profiles.json like this, nothing happened, those keybindings don't paste anything:

image

Any pointers?

Area-Input Issue-Question Product-Terminal Resolution-Answered

Most helpful comment

WTF Microsoft? I come back to Windows from macOS for a new project and this is what I find? I've been trying to copy/paste from this terminal all morning. You expect to bring devs to Windows this way?

All 25 comments

@jplew while in terminal everything u mark with the mouse is copied automatically,
right-click to twice to paste. (works for all terminal)

@Shorotshishir thanks for the reply. What if I don't want to use the mouse though? Is there a keyboard shortcut for it?

Adding with this issue, while in the terminal the new clipboard functionality doesn't work properly. If the terminal is active windows+v and click, copies the data but "uses ctrl+v" as the command to paste, thus it doesn't paste properly. if right clicked after that then it pastes. We do need quite a lot of tweaks to make all the things work together.

@jplew I am also going through the source code, I do believe there is a workaround. I need to dig deeper.

It would be nice to have some configurable copy/paste settings.

I came to open an issue as I found copy/paste difficult to use.

I'd really like to be able to double click a word to copy, triple click to select a line.
Then shift-Insert to paste

When selecting/copying text in the old "Cmd.exe" way was tricky or buggy - sometimes it didn't paste.

in CMD and PowerShell I'm used to selecting the text, press enter and it would be copied.. doesnt work in the terminal though ;( ..

Does _Ctrl+Insert_ for copy and _Shift+Insert_ for paste work for you?

From my point of view it's a pain each time I switch from one Terminal type
to another having to remember/learn different ways of
selecting/copying/pasting which is why I'd really push for providing a
choice.

Personally I've got used to and am very happy with (with MobaXTerm):

SELECTION:

  • single-click drag to select whatever I want
    double-click to select a word
    triple-click to select a line

COPY: well it was already done thank you when you selected (Nice)

PASTE:

  • shift-Insert

I guess good selection with auto-copy is the most important to me, then I
can adapt to Shift-Insert, Ctrl-V, "stand on my chair and shout" or
whatever ...

I think allowing this to be a profile setting would satisfy a lot of people.

On Mon, 24 Jun 2019 at 11:07, J. Brown notifications@github.com wrote:

Does Ctrl+Insert for Copy and Shift+Insert for paste work for you?

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/microsoft/terminal/issues/1482?email_source=notifications&email_token=AAOLALJZRDXIOADBV4INNF3P4CFFFA5CNFSM4H2ZKHMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYMIZQI#issuecomment-504925377,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAOLALLF5FNI6YIUOTJJOSDP4CFFFANCNFSM4H2ZKHMA
.

--

Cloud Native Training in English or French
-Kubernetes, Docker
-Serverless
-Micro-services
-Python, Git

shift-insert works on powershell, but not on cmd and debian. missing that...

Yea, it would be nice, the default is nifty, i miss the default select with mouse and then hitting enter for copy worked in powershell, and i think also in putty? but i don't recall.

Just to add to my previous comment, the default right-click behavior doesn't always work...for example copying 8 characters from the terminal (select characters) and then right clicking into vscode results in my previous buffer being copied, so it's not picking up my selection?

Yeah shift + insert for WSL is a must have

a PR addressing this issue was just merged into master: Connect clipboard functionality to their keybindings

Haven't tested yet. You'll probably have to build the exec yourself until new release makes it to the app store (looks like it was last updated four days ago: https://www.microsoft.com/en-ca/p/windows-terminal-preview/9n0dx20hk701)

For the remaining requests, track #524.

WTF Microsoft? I come back to Windows from macOS for a new project and this is what I find? I've been trying to copy/paste from this terminal all morning. You expect to bring devs to Windows this way?

Sorry, what's the TLDR here? Can I use the keyboard to copy and paste?

As of Version: 0.7.3382.0, I still can't find a way to paste from the keyboard.

#524 (comment) leads me to release v0.4.2382.0 which says:

You can now bind Ctrl+C to copy and it’ll still send a literal ^C if you don’t have any text selected

So I have to manually configure copying 🤔? Isn't copying and pasting from the kbd table steaks? It seems like I missing something here.

@spottedmahn You absolutely can copy/paste from/to the Windows Terminal.

By default, these are bound to Ctrl+Shift+C and Ctrl+Shift+V, respectively. These bindings were chosen for two main reasons:

  • uniformity with terminal emulators on other platforms.
  • unambiguity of Ctrl+C, which is already often used for "interrupt" in most commandline applications.

There are other threads that go into greater detail of the decision making here.

If you're unhappy with these bindings, it's _very easy_ to change them to something you prefer. There's even a guide here that you can follow.

Another default way to copy paste in terminal:
right click once on _selected text_ to copy
right click _anywhere else in terminal window_ to paste

Also does not work with tmux mouse selection.

Now we can easily copy paste by adding the keybindings in the settings:

 "globals" : 
    {
        "keybindings": [
            { "command": "copy", "keys": ["ctrl+c"] },
            { "command": "paste", "keys": ["ctrl+v"] }
        ]
    },

more on guide here

Edit: "globals" dictionnary is deprecated, you should add "keybindings" array out of it like so:

"keybindings": [
        { "command": "copy", "keys": ["ctrl+c"] },
        { "command": "paste", "keys": ["ctrl+v"] }
],

I think this should be open.
KeyBind does not work with vim on WSL.
Because it is in Visual mode.
It works with Alacritty etc.
The easiest way to get around this is to replace it with Neovim.
AnyConv com__2020-05-04 19-09-25
https://anyconv.com/api/action/download/610ec3548487c754f34397baa565675c/?name=2020-05-04%2019-09-25.mp4

"command": "copy",
"keys":["ctrl+shift+c"]

Right click the windows bar -> properties -> check use ctrl-shift-c/v etc to paste/copy

image

Thanks @PathToLife -- this is the only thing that worked for me, both in tmux, vim, vim-within-tmux.

It boggles my mind how iPad has a better terminal than windows does. Putty was great a decade ago, and yet nothing has improved. ctrl+c/v should be the defaults for copy paste. It appears to me that windows development only happens in a gui b/c the terminals are quite unusable.

@drewwells as has been noted in this thread, the default key binding for copy/paste _is_ Ctrl+c/v for new users. You can continue to complain about our open-source project and make outdated claims, or you can continue using your iPad, but you’ll have to do both of them in a new discussion thread.

Locking as resolved.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

NickITGuy picture NickITGuy  Â·  3Comments

carlos-zamora picture carlos-zamora  Â·  3Comments

zadjii-msft picture zadjii-msft  Â·  3Comments

mdtauk picture mdtauk  Â·  3Comments

warpdesign picture warpdesign  Â·  3Comments