How to Paste Code in the Terminal on Linux Mint

Share
If you are new to Linux Mint, you may have noticed that you unfortunately need to do something with the terminal instead of using a GUI, and that equally unfortunately Ctrl+V doesn't seem to work on the terminal and instead types ^V for some reason. Fortunately, there IS a way to paste in the terminal, multiple ways in fact.

However, before that:

HUGE WARNING!!!

Do NOT paste things in the terminal that you do not understand!

A Linux terminal with an explosion effect in it.
What can happen when you paste code in the terminal. Explosion: Matt Barber on Flickr. License: CC BY 2.0

There are trolls lurking on the Internet who think it's funny to tell people to Alt+F4 or delete system32, except that on Linux the joke is will be rm -rf /, which is much worse than deleting system32 on Windows because this will delete all your files, and it may not be possible to recover them at all.

Before continuing, make sure you read [Dangers of Copy Pasting Linux Terminal Commands that You Don't Understand] so you at least you are aware of common risks.

Menubar Method

The first way to paste things in the terminal is to click on Edit -> Paste on the menubar. On Linux Mint, the default terminal emulator is the GNOME Terminal, and its default keyboard shortcut for pasting is Ctrl+Shift+V instead of Ctrl+V. The same shortcut may also work on other terminals like KDE's Konsole.

Context Menu Method

You can also find the option to paste the code from the clipboard in the context menu that opens when you right click on the terminal.

Middle Click Method

On Linux, there's a convention of making the middle mouse button perform actions such as closing tabs and tasks on the taskbar, and pasting things on text editors. This also applies to the terminal. If you middle click, the code will be pasted.

On Nano, Vi, Vim, Neovim

If you're using a terminal-based text editor like Nano, Vi, Vim, or Neovim, you can also paste code copied from outside the editor by middle clicking somewhere (on Vi and its descendants while in insert mode).

It's worth noting that the Vi-likes have a command, p, which will paste code that you copied inside Vi using commands like yank (yy) and delete (dd). This command, confusingly, doesn't paste code copied from outside Vi. To do that, you need to specify the system clipboard as the buffer using "*.

If you are not using the GUI, or if you don't like using a menu, you have to
use another way.  You use the normal "y" (yank) and "p" (put) commands, but
prepend "* (double-quote star) before it.  To copy a line to the clipboard:

	"*yy

To put text from the clipboard back into the text:

	"*p

This only works on versions of Vim that include clipboard support.  
https://vimdoc.sourceforge.net/htmldoc/usr_04.html#04.7 (accessed 2025-02-19)
Written by Noel Santos.

About the Author

I'm a self-taught Brazilian programmer graduated in IT from a FATEC. In a world of increasingly complex and essential computers, I decided to use my technical expertise in hardware, desktop applications, and web technologies to create an informative resource to make PC's easier to understand.

View Comments