stop pasting tons of style garbage into your emails!
© 2012 by KV5R.
The Problem
When composing an HTML email in Thunderbird, “Paste” (Ctrl-V) pastes in a ton of style formatting, when something was copied from a web page or other formatted document. This is very annoying, since the incoming formatting code messes up the formatting of the email. Even worse, when copying from Chrome, the paste brings in a load of useless “apple-span-class” and “-webkit” crapola into the message’s HTML. All that extra bloat is unnecessary, unless you actually want to paste something with its source formatting into an email.
You should locate and install the “EditHtml” add-on so you can see (and edit or remove) the loads of excess HTML that paste operations bring in. It’s also handy to clean up messy emails before forwarding them.
Example
Here’s the HTML of a blank message:
<head></head> <body bgcolor="#FFFFFF" text="#000000"><br></body>
Here’s the HTML of the same message after pasting in one tiny link copied from a web page in Google Chrome:
<head></head> <body bgcolor="#FFFFFF" text="#000000"> <a href="http://getsatisfaction.com/mozilla_messaging/people" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; outline-width: initial; outline-style: none; outline-color: initial; font-weight: normal; font-style: normal; font-size: 13px; font-family: verdana; vertical-align: baseline; color: rgb(25, 81, 144); text-decoration: none; font-variant: normal; letter-spacing: normal; line-height: 15px; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(88, 94, 98); ">the<span class="Apple-converted-space"> </span> <span class="notranslate" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; outline-width: 0px; outline-style: initial; outline-color: initial; font-weight: inherit; font-style: inherit; font-size: 13px; font-family: inherit; vertical-align: baseline; ">Mozilla Messaging</span> <span class="Apple-converted-space"> </span> team</a> <span style="color: rgb(136, 136, 136); font-family: verdana; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 15px; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(88, 94, 98); display: inline !important; float: none; ">.</span> </body>
That’s just a wee bit much, considering I didn’t want any of the web page’s formatting in my email, much less all that crap… And can you imagine how much extra crap that would be if I copied a large portion of a web page? EEK!
Okay, so you can use the “Paste Without Formatting” item on the Edit menu, but it’s inconvenient. Obviously, “Paste Without Formatting” should be the default paste operation. The Edit menu should then have a “Paste With Formatting” option. Looks to me like it’s just a matter of swapping two key assignments — Ctrl-V and Ctrl-Shift-V — or better yet, there should be a config entry to set the default type of paste function in Thunderbird’s settings.
How To Fix It
All one needs do is swap the key-bindings for Ctrl-V and Ctrl-Shift-V. This is done in two files within the file omni.ja, a large zipped file containing most of the Javascript and XML that runs Thunderbird. The one first is:
c:\Program Files (x86)\Mozilla Thunderbird\omni.ja\chrome\toolkit\content\global\platformHTMLBindings.xml
(On non-x64 Windows machines, remove the " (x86)" above)
- First, make a copy, in the same folder, of omni.ja, such as omni.ja.bak, just in case you mess it up.
- Rename omni.ja to omni.zip
- Unzip it into an empty folder such as C:\temp
- Navigate to C:\temp\chrome\toolkit\content\global\ and find platformHTMLBindings.xml
- Open it in a text editor
- Search for pasteNoFormatting and see these two lines:
- Save the file and close the editor.
- Now locate and edit C:\temp\chrome\messenger\content\messenger\messengercompose\messengercompose.xul.
- Search for key_paste and see these three lines:
<key id="key_paste" key="&pasteCmd.key;" modifiers="accel"/> <key id="pastequotationkb" key="&pasteAsQuotationCmd.key;" observes="cmd_pasteQuote" modifiers="accel, shift"/> <key id="pastenoformattingkb" key="&pasteNoFormattingCmd.key;" modifiers="accel, shift" observes="cmd_pasteNoFormatting"/>
- ...and move that comma and shift up into the modifiers in the “key_paste” line, thus:
<key id="key_paste" key="&pasteCmd.key;" modifiers="accel, shift"/> <key id="pastequotationkb" key="&pasteAsQuotationCmd.key;" observes="cmd_pasteQuote" modifiers="accel, shift"/> <key id="pastenoformattingkb" key="&pasteNoFormattingCmd.key;" modifiers="accel" observes="cmd_pasteNoFormatting"/>
- Now you have swapped the Ctrl-V and the Ctrl-Shift-V on the Edit menu (it will not work unless you do so).
- Save the file and close the editor.
- Now Zip up the whole folder structure as omni.zip (make sure your zip does “recurse folders and store pathnames” or similar wording).
- Rename it to omni.ja
- Copy it over the old omni.ja in the Thunderbird install folder.
- Now nav to {youruserprofile}\AppData\Local\Thunderbird\Profiles\{whatever}.default\startupCache\startupCache.4.little (or similar) and DELETE it. If you don't, the old settings will still be cached.
- Now fire up Thunderbird and see if it works. Start a New message and look at the edit menu. The Paste and Paste Without Formatting keys should be reversed:
Paste = Ctrl+Shift+V Paste Without Formatting = Ctrl-V
- Open a browser and select and copy something.
- Paste it into a new message with Ctrl-V. It should paste as plain text in the email’s default body font.
- Now try pasting it with the Edit menu commands. It should paste as the commands say: Paste will be with formatting.
- All done.
<handler event="keypress" key="v" command="cmd_paste" modifiers="accel"/>
<handler event="keypress" key="v" command="cmd_pasteNoFormatting" modifiers="accel, shift"/>
Drag and drop the ", shift" part up into the line above it, thus:
<handler event="keypress" key="v" command="cmd_paste" modifiers="accel, shift"/>
<handler event="keypress" key="v" command="cmd_pasteNoFormatting" modifiers="accel"/>
Now you have swapped the commands associated with Ctrl-V and the Ctrl-Shift-V.
Notes
- This does not change the Shift-Insert paste key sequence. It only reverses Ctrl-V and Ctrl-Shift-V.
- Updating Thunderbird will revert your changes (you get a new omni.ja) and you have to do it all over again.
- Some file and zip managers (Total Commander, for example) will allow you to navigate within archives, edit a file therein, then repack it into the archive. This makes the above procedure much easier, since you don’t have to unpack and repack omni.ja.
I saw some chatter on the Mozilla Developer's Forum (I think it was there) about externalizing the key bindings to a user file, but we'll just have to wait to see if it's ever done.
I have my Logitech mouse programmed to Copy and Paste when the wheel is pressed left or right — the side buttons in the wheel simply send Ctrl-X and Ctrl-V into the keyboard buffer. After getting used too it, I find it is hugely helpful — you already have your hand on the mouse to select some text; you then just pull the wheel left, switch windows, then push the wheel right. Very handy!
So there ya go! One more little aggravation eliminated!
—kv5r
I should have mentioned that this was v2.2.0 of tb-keys-lite with v102.5.0 of Thunderbird.
I should also mention that at first I got nothing in the Options tab for tb-keys lite and so I tried restarting Thunderbird. But Thunderbird crashed every time I tried to launch it. So I reinstalled Thunderbird 102.5.0 and both Thunderbird and the tb-keys add-on worked fine after that, and I got the expected fields in the Options tab for tb-keys lite.
Thanks kv5r. I found a way to do it with the current version of Thunderbird. You install this add-on:
https://addons.thunderbird.net/en-US/thunderbird/addon/tbkeys-lite/
But first you have to unzip it and change “strict_max_version:” to “107.0” in the manifest.json, as described by botti56 in the reviews, and re-zip it.
Then after installing it, as described at:
https://github.com/wshanks/tbkeys
you add the following to the “Compose key bindings” field in the options tab, and hit the Save button.
{
“ctrl+v”: “cmd:cmd_pasteNoFormatting”,
“ctrl+shift+v”: “cmd:cmd_paste”
}
Regards,
— Dave
Thank you so much for posting this. But 10 years later, things have changed and these instructions no longer work. Can you figure out how to do the same thing with today’s Thunderbird. It could be sanity-saving.
Howdy Dave,
You are correct. I just made an extensive full-text search within omni.ja and other thunderbird files and keybindings are no longer exposed. So it isn’t possible to remap them, and in any case, an update overwrites any changes.
Thanks for finding this outdated info. I will remove this article when you have received this message.
Best wishes, –kv5r