Sublime Text 2 Paste with Colors to MS Word - sublimetext2

I would like to paste my code to a word document while preserving the highlighted, colored texts. Is there a way to do this?

You can install highlight plugin and then use SublimeHighlight: copy to clipboard as RTF command from the command palette.
If you want to use your own color scheme use ExportHTML plugin to export to html and copy and paste the html in MS Word.
HTMLExport can be configured to use any of your installed color schemes. just read the docs and look at the default settings.
Use a browser like Safari that can copy in RTF to the clipboard. For me chrome does not work.

My Answer here, is for people who Don't know how to install SublimeHighlight Package on Sublime Text 3:
Install Package Control inside sublime text 3. If you don't know how, follow this link here
Open the Sublime Command Palette by pressing CTRL+SHIFT+P` on Windows or ⌘+⇧+P on Mac
Type "Add Repository", and press enter
Then paste this link https://github.com/n1k0/SublimeHighlight/tree/python3
Press CTRL+SHIFT+P on Windows or ⌘+⇧+P on Mac again and type "Install package" and press enter or return
Type "Sublime highlight" and press enter to install the plugin
Restart your Sublime
How to Use SublimeHighlight
Highlight the Text you want to copy
Press CTRL+SHIFT+P
Type, for example, "SublimeHighlight: copy to clipboard as RTF: " like so:
Paste it in Word or Powerpoint, you will find the text has been pasted with coloring and formatting.
These are the commands you can use:
SublimeHighlight: convert to HTML: will convert current code to highlighted HTML in a new SublimeText tab.
SublimeHighlight: convert to RTF: will convert current code to highlighted RTF in a new SublimeText tab.
SublimeHighlight: view as HTML: will convert current code to highlighted HTML and open it in your default browser.
SublimeHighlight: view as RTF: will convert current code to an RTF document and open the generated file with your default program.
SublimeHighlight: copy to clipboard as HTML: will convert current code to highlighted HTML and store it into the system clipboard.
SublimeHighlight: copy to clipboard as RTF: will convert current code to raw highlighted RTF and store it into the system clipboard.
Customizing the Theme (OPTIONAL):
go to Preferences --> Package Settings --> SublimeHighlight --> Settings-User.
paste this code
{
"theme": "fruity",
"linenos": "inline",
"noclasses": true,
"fontface": "Menlo"
}
Here, I have used the "fruity" theme, you can choose whatever you like. These are all possible themes:
Set Hotkey (OPTIONAL)
In the next code, I have set the CTRL+ALT+C to copy the text with formatting, you can do that following these few steps:
Go to Preferences --> Key Bindings-User.
Paste this code:
{ "keys": ["ctrl+alt+c"],
"command": "sublime_highlight",
"args": { "target": "clipboard",
"output_type": "rtf"
}},
`
Now whenever you copy a text with CTRL+C, it will be copied without formatting and with CTRL+ALT+C, it will be copied with coloring :)

The SublimeHighlight plugin does work well! But as Jorre noted, code can lose some colors. I found that the selection you are copying to the clipboard matters.
When, for example, I select a portion of a CSS stylesheet, but the selection does not include the closing style tag, the colors will be lost. It appears that any incomplete element will be copied to the clipboard as white text.
My solution has been to simply copy the entire code file to the clipboard as RTF, paste into Word, then make the selection there for further copy / pasting into a PowerPoint slide or elsewhere.

Related

How do I modify the VS Code HTML formatter?

Currently trying to write some HTML for something. VS Code did an update yesterday and now the auto-formatter (Alt+Shift+F) is a different set of options and is overriding everything.
How do I access that specifical file to modify it. I currently have "Prettier" installed but it does not handle HTML
Right-click in your text editing area and choose Format Document With.... A popup will appear on top then choose Choose default formatter and then choose Prettier
You can trigger suggestions at any time by pressing Ctrl+Space.
To improve the formatting of your HTML source code, you can use the
Format Document command Ctrl+Shift+I to format the entire file or
Format Selection Ctrl+K Ctrl+F to just format the selected text.
Read this: https://code.visualstudio.com/docs/languages/html

How to open a different tab in same folder using sublime text or visual studio code?

I use sublime text 3 and visual studio code, but i found that if i open a different file in same folder , it does not open a different tab, instead the new tab will replace the old tab. How do I get a file to open in a different tab in same folder ?
I'm not familiar with VSCode, but in Sublime, single clicking a file opens it in a semi-transient view for preview purposes. You can tell this is happening by the file name in the tab being italicized.
The reason for this is to allow you to quickly preview files for editing without having an excessive number of tabs open. So when you single click on another file, the existing preview tab is reused for the new file.
In order to commit the tab to being a "fully opened" file, you can either double click the file to tell Sublime that you want to edit it, or make a modification to the file in the buffer.
This is controlled by the setting preview_on_click, which is turned on by default. If you turn this off, single clicking files will not preview them, so you need to double-click files in order to open them.
In both editors, if you single click a file it remains in a single tab that is re-used by other single-clicked files. If you double click the file, it opens it in a new tab. At a glance, you'll also notice that the "single click tab" title is italicized, while the ones you double clicked are regular text.

How do I copy html, css, Javascript code from email

I am trying to copy code from an email into a a Web page file. I would like the file to have functionality.
I tried copying it directly into a new Sublime file but the colors did not appear as if I had typed it in. When I right clicked background, no open in browser option appeared. I am experimenting with code snippets in blogs and having problems pasting code with functionality in tact. Is this an extension omission ?
Thanks
Sublime will copy plain text, a wysiwyg html editor will copy the markup. If you want to get the markup, do 'show original' (gmail) or whatever your client has as an equivalent. The original will have the markup and can be copied into Sublime. Hope that helps.

Sublime & Highlight: pasting as RTF fontsize issue

I downloaded a package named SublimeHighlight for the Sublime text editor. It serves as my solution to paste syntax highlighted code into Evernote. I have both Evernote and Sublime using the Menlo mono-spaced font. I select text in Sublime, right click and choose "copy as RTF". Pasting into Evernote retains the syntax coloring and indentation. So far so good.
In Evernote I have my default font size set to 14. No matter what my font size is set to in Sublime, when I paste into Evernote the font size is 12. I found this page via google which shed a bit of light on the situation: pygments, used by SublimeHighlight, has a default font size of 12 (do a 'find' on the page for 'fontsize' and you'll see it). The problem is I don't know python (what pygments and SublimeHighlight are written in) and have no idea how to change the font size of pasted-in text from Sublime to Evernote.
All I'm looking for is to past syntax highlighted code from Sublime into Evernote at the correct font size.
EDIT:
I just downloaded Atom and a package for it called Copy as RTF. It works flawless. I really wanted to stay within the Sublime ecosystem, but Atom just works. Plus, Copy as RTF for Atom has more recent updates than SublimeHightlight for Sublime. Whatever works, right?
May be you can try to use UltraEdit, which can help you copy your code as RTF or HTML and paste them into Evernote.
and then
More details can be found here
Or you can try Notepad++ and use the NppExport plugin.
and change the font size you want in Words or Outlook
Check here for more detail
Hope it helps.

Is there a way to export code to HTML in Eclipse?

I know NetBeans has this feature, but I can't find it in Eclipse. A quick search for plugins was not successful.
Java2Html - Eclipse Plugin:
Convert files:
Select items in the Package Explorer, Navigator or other views and right click to open the context menu. There is a Java2Html menu item that opens the conversion dialog.
Convert text from a text editor:
Right click on an editor and choose the Java2Html context menu item to convert the current selected text.
Adjust preferences:
Colors, tab size, etc. for conversion can be adjusted on the preference pages (Menu "Window" - "Preferences" - "Java" - "Java2Html")...
Hackish way:
On Windows at least, when you do Ctrl-A (Select all), Ctrl+C (Copy) what actually gets copied to the clipboard is formatted text (with all the colors and fonts). Then you can paste (Ctrl-V) it to something that can accept formatted text, say Microsoft Word or even Wordpad and save it to whatever format you wish.
The Copy as HTML eclipse IDE plugin allows us to directly copy our
code as HTML and paste it to our blogs or forums without any
formatting.
Download Copy as HTML eclipse plugin
Steps to install the plugin:
Download the Copy as HTML eclipse plugin
Copy it to the 'dropins' folder of your eclipse installation
If 'dropins' folder is not present then copy it to the 'plugins' folder of your eclipse installation
Restart eclipse IDE
That's it
Steps to Use
Select the code or text to be copied
Select 'Copy as HTML' option or press 'cntrl+shift+3'
Paste it your superb blog
Taken from here:
http://java-sample-program.blogspot.hu/2012/12/copy-as-html-eclipse-plugin.html