How to copy/paste text without formatting by default?

Solution 1:

In fairly recent Ubuntus you can use Ctrl-Shift-v to paste plain text.

Solution 2:

I use parcellite Install parcellite. It keeps a history of the clipboard.

Solution 3:

I've found a way to achieve this after some searching online and experimenting with my environment.

You can create a custom shell script which you can then bind to a key shortcut in your desktop environment. I'm using Xfce on Linux Mint (which is based on Ubuntu). Xfce allows me to override Ctrl-C by simply defining that as the shortcut in Settings -> Keyboard -> Application Shortcuts, but I prefer using a different shortcut, Ctrl-Alt-C, so that I'm still able to copy with formatting in the rare cases I need to.

Here's how I did it.

Install xclip:

apt-get -y install xclip

I don't know about other desktop environments, but Xfce didn't like me using a pipe in the custom keyboard command, so I had to make a script with the xclip-line, which is then bound to my keyboard shortcut (Ctrl-Alt-C).

My personal habit is putting custom commands in ~/.bin and then adding that directory to the PATH variable.

Here's how you do that, if so inclined:

mkdir ~/.bin
echo 'export PATH=~/.bin:$PATH' >> ~/.bashrc

(Note that you will need to re-initialize your session for that change to take effect, meaning you'll have to log out of your desktop environment and back in again. See if it worked by typing echo $PATH in a terminal after having logged in again.)

I've then created the script ~/.bin/copy-without-formatting with the following content:

#!/bin/bash
xclip -o | xclip -selection clipboard

Remember to make it executable with the following line:

chmod +x ~/.bin/copy-without-formatting

Then, since I'm using Xfce, I've gone to Settings -> Keyboard -> Application Shortcuts and added a shortcut with the full path to the script, without variables or a tilde. So if my username were mrgaga, the string would be /home/mrgaga/.bin/copy-without-formatting. Then I've configured the shortcut.

Xfce activates the changes immediately when I've closed the window so you should be able to check if it works right away, without logging out and in again, at least if your environment is similar enough to mine.

I hope it helps.

Solution 4:

I don't know of a way to do it automatically. A workaround of course is to paste it into gedit Install gedit and copy it from there.