How to copy and paste code without rich text formatting?

EditorCopy Paste

Editor Problem Overview


I used to often find myself coping a piece of code from a website/Word document etc only to discover that when doing Paste I would end up with the desired code plus some extra HTML tags/text, basically extra formatting information.

To get rid of that extra ballast I would paste the text to the Notepad and then copy it again and then paste to the desired destination.

Pretty recently I discovered a simple and free tool for Windows called PureText that allows me to cut the Notepad step. It basically adds an extra keyboard shortcut e.g WinKey + V that will do the Paste action without formatting; just pure text. I find it very handy.

I was wondering what approach would you use yourselves? Are they any better/easier to use tools around?

Editor Solutions


Solution 1 - Editor

Just to summarize the available options:

Tools

Browsers

  • To copy plain text from a browser: Copy As Plain Text or CopyPlainText (suggested by cori) - Firefox extensions
  • To paste without formatting to a browser (Firefox/Chrome at least): CTRL+⇧ Shift+V on Windows/Linux, see below for Mac OS X.

Other

  • Under Mac OS X, you can ⇧ Shift+⌥ Alt+⌘ Command+V to paste with the "current" format (Edit -> Paste and Match Style); or ⌘ Command+⇧ Shift+V to paste without formatting (by Kamafeather)
  • Paste to Notepad (or other text editor), and then copy from Notepad and paste again
  • For single-line text: paste to any non-rich text field (browser URL, textarea, search/find inputs, etc.)

Please feel free to edit/add new items

Solution 2 - Editor

Just for reference, under Mac OS X, you can use ⌘ Command+⇧ Shift+V to paste without formatting or with the "current" format.

Note: in some apps it's ⌘ Command+⇧ Shift+⌥ Alt+V (see "Edit" Menu → "Paste and Match Style")

Solution 3 - Editor

I'm a big fan of [Autohotkey][1]. [1]: http://www.autohotkey.com.

I defined a 'paste plain text' macro that works in any application. It runs when I press Ctrl+Shift+V and pastes a plain version of whatever is on the clipboard. The nice thing about Autohotkey: you can code things to work the way you want them to work across all applications.

^+v::
	; Convert any copied files, HTML, or other formatted text to plain text
	Clipboard = %Clipboard%

    ; Paste by pressing Ctrl+V
    SendInput, ^v
return

Solution 4 - Editor

From websites, using Firefox, I use the CopyPlainText extension.

Solution 5 - Editor

If you're pasting into Word you can use the Paste Special command.

Solution 6 - Editor

I have Far.exe as the first item in the start menu.

Richtext in the clipboard ->

ctrl-escape,arrdown,enter,shift-f4,$,enter
shift-insert,ctrl-insert,alt-backspace,
f10,enter

-> plaintext in the clipboard

Pros: no mouse, just blind typing, ends exactly where i was before

Cons: ANSI encoding - international symbols are lost

Luckily, I do not have to do that too often :)

Solution 7 - Editor

Nice find with your PureText. I had build, before I change keyboard, a key that was running a macro that was copying-pasting-copying in notepad for this task! I'll give a try to your software since I do not have any macro key now :(

Solution 8 - Editor

I wrote an unpublished java app to monitor the clipboard, replacing items that offered text along with other richer formats, with items only offering the plain text format.

Solution 9 - Editor

Look for a little clipboard icon that pops up at the end of the material you pasted. Click on this and choose "keep text only".

Solution 10 - Editor

I use OpenOffice.org and that offers a paste special option, where you can omit the formatting altogether. If you are not bound to MS Word, it's IMO worth a try and it's free :-)

Solution 11 - Editor

Whenever these plugins and options aren't available I just use my good ol friend notepad. Paste content into notepad where it won't accept the extra formatting and then copy it right back out. Sort of hacky but oh well. It works!

Solution 12 - Editor

I usually work with Notepad2, all the text I copy from the web are pasted there and then reused, that allows me to clean it (from format and make modifications).

You can download Notepad2 here

Solution 13 - Editor

If you are using MS Word then try ALT+E, S, U, Enter (Uses the Paste Special)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionkristofView Question on Stackoverflow
Solution 1 - EditorkristofView Answer on Stackoverflow
Solution 2 - EditorMartin MarconciniView Answer on Stackoverflow
Solution 3 - EditorDean HillView Answer on Stackoverflow
Solution 4 - EditorcoriView Answer on Stackoverflow
Solution 5 - EditorhometoastView Answer on Stackoverflow
Solution 6 - EditoreugenskView Answer on Stackoverflow
Solution 7 - EditorPatrick DesjardinsView Answer on Stackoverflow
Solution 8 - EditorStephen DenneView Answer on Stackoverflow
Solution 9 - EditorSteve PitchersView Answer on Stackoverflow
Solution 10 - EditorAndréView Answer on Stackoverflow
Solution 11 - EditorSmallinovView Answer on Stackoverflow
Solution 12 - EditorebarreraView Answer on Stackoverflow
Solution 13 - EditorrevaView Answer on Stackoverflow