Is there any way to assign geany highlight to text. For example when I pass a programming code to geany. Functions color is red. The thing which I am looking for is assingning these color to text. For example if I open that with another editor (which does not highlight the text) the colors remain.


The syntax color feature is provided per filestype by the IDE/editor and there's no way to export it or save it as part of the original text file.

If your goal is to present the original source with syntax highlighting, I'd suggest to use http://tohtml.com/ and save the rich text preview into a document that supports this format, like ODF text document.

  • In this link I can find for all languages and scripts, Not just python – Mohammad Reza Rezwani Apr 8 '14 at 18:08

First of all, there is some basic concept here: the programs and the source code that you are editing are pure text --- there is no color or style information in the file. It is the editor that decides what color and style to apply when showing it to you. You can easily check that different editors will highlight the structure of your code in different ways. This thing is called syntax highlight. See for example how vim and gedit render the same file:

gedit and vim syntax hl

Now you can export a syntax highlighted version of your code to various formats, but remember: this will not be code anymore, but a document; you cannot compile and execute it.

My preferred tool for that is pygmentize. You can install it with sudo apt-get install python-pygments. For example,

 % pygmentize -f html -o out.html  imgsize.py

will create an html version of your code, usable for web publishing, and

 % pygmentize -f rtf -o out.rtf  imgsize.py

will create an .rtf that you can read with Libreoffice or MS Word. There are a lot of formatters available.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.