How to Paste into a Terminal

How to paste into a terminal?

Gnome terminal defaults to ControlShiftv

OSX terminal defaults to Commandv. You can also use CommandControlv to paste the text in escaped form.

Windows 7 terminal defaults to CtrlShiftInsert

How to copy and paste in Vim's terminal mode?

Copy

To copy from a terminal window press CTRL-W N (This is a capital N)1 or CTRL-\ CTRL-N (this is not a capital N) to get into normal mode. From there you can use all usual vim commands to copy and paste stuff.

Entering insert mode will drop you back to your shell.


Paste

To paste from a register into the terminal window you have to be in Terminal-Job ("insert") mode.

Press CTRL-W " followed by the register.


:help Terminal-mode tells us:

When the job is running the contents of the terminal is under control of the
job. That includes the cursor position. Typed keys are sent to the job.
The terminal contents can change at any time. This is called Terminal-Job
mode.

Use CTRL-W N (or 'termkey' N) to switch to Terminal-Normal mode. Now the
contents of the terminal window is under control of Vim, the job output is
suspended. CTRL-\ CTRL-N does the same.

[...]

In Terminal-Normal mode you can move the cursor around with the usual Vim
commands, Visually mark text, yank text, etc. But you cannot change the
contents of the buffer. The commands that would start insert mode, such as
'i' and 'a', return to Terminal-Job mode.

See :h terminal-typing for more useful commands in terminal windows.


1Unfortunately the vim help doesn't tell you that it is a capital N, I kept the original notation

Copy Paste in Bash on Ubuntu on Windows

Update 2019/04/16: It seems copy/paste is now officially supported in Windows build >= 17643. Take a look at Rich Turner's answer. This can be enabled through the same settings menu described below by clicking the checkbox next to "Use Ctrl+Shift+C/V as Copy/Paste".


Another solution would be to enable "QuickEdit Mode" and then you can paste by right-clicking in the terminal.

To enable QuickEdit Mode, right-click on the toolbar (or simply click on the icon in the upper left corner), select Properties, and in the Options tab, click the checkbox next to QuickEdit Mode.

With this mode enabled, you can also copy text in the terminal by clicking and dragging. Once a selection is made, you can press Enter or right-click to copy.

How paste command into WinSCP terminal window?

Righ-click on the Window header → Edit → Paste:
Sample Image

UPD: By the way, if you want to paste it without doing this every time, right-click on the Window header, choose "Properties", enable "QuickEdit Mode", and click "OK". Now you can paste strings with a single "right-click".

How to paste clipboard text in VS Code Terminal

Got answer, link

Right-Click on the cursor line did the trick

Sample Image

How do you copy and paste into Git Bash

Press Insert.

Also, to copy from the window, try clicking the console's window icon (topleft) and choosing Edit -> Mark, then drag a box on the text, then press Enter. (You can also paste via the window icon menu, but the key is faster.)

UPDATE

Starting from Windows 10 the CTRL + C, CTRL + V and a lot of other feature are implemented in conhost.exe so they should work with every console utility on Windows. (You have to enable Properties -> Option tab -> Quick Edit Mode)

Ref: http://blogs.windows.com/buildingapps/2014/10/07/console-improvements-in-the-windows-10-technical-preview/

Windows 10 built-in SSH Client. How to paste the password?

The answers to Copy and Paste in Windows PowerShell (the link given in the other answer by Chris) suggest 5 different ways to paste text. They all work on the plain command line, but only 3 of them work for the ssh password (or when entering any text into the ssh app, such as after you've successfully logged in).

The five are:

  1. press right-click on the mouse
  2. use the mouse to open the context menu and click the Edit > Paste option
  3. hit Ctrl + V on the keyboard
  4. use the keyboard to access the context menu's Edit > Paste option: Alt + Space, then E, then P
  5. if the "Use Ctrl+Shift+C/V as Copy/Paste" option is activated, hitting Ctrl + Shift + V on the keyboard

The three that work for ssh are numbers 1, 2 and 5. (As the other answers mention, the ssh login prompt doesn't echo the pasted characters, and you'll need to press Enter after pasting.)

Why don't all 5 methods work?

The tool-tip for the option for number 5 gives a hint as to what's going on.

screenshot of Windows PowerShell Properties window, Options tab, showing tooltip on "Use Ctrl+Shift+C/V" option

It says "regardless of input mode". The options dialog also has a new console features link, which has the following:

If you run in processed input mode, the shortcuts below apply, but in
other modes, your application must handle them

(where "shortcuts below" include Ctrl + V)

So I think that ssh runs in a mode other than "processed input mode" (and doesn't itself handle those shortcuts in the expected way) which is what apparently causes methods 3 and 4 to not work.

Copy and Paste in linux terminal

That ultimately depends on your terminal and display server setup (X11 in most cases), but you can try these two things:

  1. Often you can simply select the text to be copied with your mouse (without pressing any keys) and paste by pressing the middle mouse button (or pressing the scroll wheel).
  2. If that doesn't work, try selecting with your mouse, then press SHIFT-CTRL-C to copy and SHIFT-CTRL-V to paste. Notice the extra SHIFT here. CTRL-C without SHIFT does something else entirely and would send an interrupt signal to the currently running process.

Alternatively, you can use some tool like xclip. E.g. on ubuntu do apt-get install xclip. Then you can copy to your clipboard, e.g. by doing

echo "Hello World" | xclip

and paste with

xclip -o
>>> Hello World

PowerShell console in Visual Studio Code: How to copy-paste?

Ctrl+C and Ctrl+V for copying / pasting work as-is in Visual Studio Code's integrated terminal.

By contrast, right-click behavior is configurable:

  • On Windows, the default behavior is to copy, if text is currently selected, and paste otherwise - as in regular console windows.

  • To get the same behavior as in the Windows PowerShell ISE, i.e. to instead show a shortcut menu, which contains Copy and Paste commands, add the following line to your settings.json file (before the closing }):

"terminal.integrated.rightClickBehavior": "default",

Alternatively, use the settings GUI (press Ctrl+,):

right-click behavior setting

Note:

  • The screenshot was taken on macOS, where selectWord is the default setting; on Windows, it is copyPaste, with the behavior as described above.

  • Also note the GUI's convenient search feature: typing right click in the search field was sufficient to locate the relevant setting.



Related Topics



Leave a reply



Submit