Hot answers tagged

99

The nano editor provides syntax highlighting for a few languages and scripts by itself. Check out /usr/share/nano/ nits@nits-excalibur:~$ ls /usr/share/nano/ asm.nanorc fortran.nanorc man.nanorc ocaml.nanorc ruby.nanorc awk.nanorc gentoo.nanorc mgp.nanorc patch.nanorc sh.nanorc c.nanorc groff.nanorc mutt.nanorc perl....


43

Yes you can, however the default syntax definitions are quite poor and incomplete. I'm maintaining a more accurate set of definitions here, for anyone who finds them useful. To install, run: git clone https://github.com/nanorc/nanorc.git cd nanorc make install Add these lines to the ~/.nanorc include ~/.nano/syntax/html.nanorc include ~/.nano/syntax/css....


18

You can at least add file extensions in the html syntax coloring scheme by editing html.lang in /usr/share/gtksourceview-2.0/language-specs/ as a super user. So say you want to add HTML syntax highlighting to cfm files, you'd change this <property name="globs">*.html;*.htm</property> (default html.lang) into this <property name="globs">*...


15

I used this command to quickly enable all available languages. find /usr/share/nano/ -iname "*.nanorc" -exec echo include {} \; >> ~/.nanorc As mentioned in other answers, /usr/share/nano/ contains the definitions for different languages. $ ls /usr/share/nano asm.nanorc fortran.nanorc man-html ocaml.nanorc ruby.nanorc awk.nanorc ...


13

Gedit (the default text editor) using GTKSourceView for it's syntax highlighting. It uses XML files to define how to highlight different syntax. There is a tutorial and a reference document on the GTKSourceView site. Finished source file definitions are stored in /usr/share/gtksourceview-2.0/language-specs/, you might want to check them out to learn by ...


8

This is not possible without modifying the source code of Gedit or writing a plugin to override the default. The default syntax highlighting scheme is hard-coded.


7

You can create your own language definition files in your $HOME directory. Editing the gtk language specs is not recommended as it will be overriden by every gtksourceview update. Copy your language specs file to your home directory: $ cp /usr/share/gtksourceview-3.0/language-specs/html.lang ~/.local/share/gtksourceview-3.0/language-specs/ Then, add ...


6

Create and open your fortune language file: sudo touch /usr/share/gtksourceview-3.0/language-specs/fortune.lang sudo -i gedit /usr/share/gtksourceview-3.0/language-specs/fortune.lang Paste the following: <?xml version="1.0" encoding="UTF-8"?> <language id="fortune" _name="Fortune" version="2.0" _section="Markup"> <metadata> <...


3

The reason for the special highlighting of the first sentence is to emphasize that it is the summary of the Javadoc comment. The first sentence of a Javadoc comment is handled specially by the Javadoc tool, see this description of how Javadoc comments are interpreted.


3

I got the github link to work. The steps I took was the following: Copy the files to a folder. smarty.lang smarty.xml smarty.sh Navigate to the folder with the cd command in a terminal. Make smarty.sh executable chmod +x ./smarty.sh And finally install it! ./smarty.sh


3

You can define this by yourself. Here is a good example from Arch Linux Forums. Copy the following code and save it in /usr/share/nano/ as conf.nanorc # config file highlighting syntax "conf" "(\.(conf|config|cfg|cnf|rc|lst|list|defs|ini|desktop|mime|types|preset|cache|seat|service|htaccess)$|(^|/)(\w*crontab|mirrorlist|group|hosts|passwd|rpc|netconfig|...


3

It will require a few steps but everything can be done using the command line: Install the following dependencies: sudo apt-get install aha wkhtmltopdf python-pygments Prettify your json file: cat foo.json | python -m json.tool > bar.json Call pygmentize to get syntax highlighting and export it to html with aha: pygmentize bar.json | aha > bar....


2

to enable syntax highlighting in vim you have to enable it thrugh vimrc. add syntax on to your vimrc. here is the typical script for groovy. I donot know if it is compatible with vi or not because I am also novice to vi/vim. You can install the full vim with sudo apt-get install vim


2

I do not know why your original julia.lang file is not working since you're not showing the source, but the one you based on matlab.lang will not work because there's no context inside <definitions> with the same id you mentioned for <language>. Basically, you're saying the id of this language is julia, but there is no context with that id being ...


2

It was easier than I expected. I must to use: export LESSOPEN='|pygmentize %s'


2

I have some nano syntax highlighting at my github. There are live example screenshots for html and php: and


1

You can actually do this with Gedit, the default text editor Ubuntu ships with. Simply open up your file in Gedit and make sure it's properly syntax-highlighted. Then go to File → Print and select Print to File as the printer and PDF as the output format. This should result in a properly syntax-highlighted PDF file. For other more scriptable solutions make ...


1

Since you already have a pattern to match, I think you could use an offset for the highlighting. From the vim documentation: *:syn-pattern-offset* The pattern can be followed by a character offset. This can be used to change the highlighted part ... Example: :syn match String /"[^"]*"/hs=s+1,he=e-1 some "string" text ^^^...


1

Yes, of course: pygmentize -g /file/to/show | less -r


1

You could change /usr/share/gtksourceview-3.0/language-specs files but instead copy this file to your home or you will lose changes on upgrade. $ cp /usr/share/gtksourceview-3.0/language-specs/octave.lang ~/.local/share/gtksourceview-3.0/language-specs/ change <property name="globs">*.m</property> to <property name="globs"></property> ...


1

No sorry, only by double clicking can this work. If you can scroll the text use control+shift+arrow to highlight the word in the direction of the arrow.


1

i really really really like geany, however it doesnt really provide the kind of answer you're looking for. iSeth's suggestion is close to the best in my opinion, but doesnt really tell you how to use it. you may have already figured it out, but like most applications, vim accepts in put from STDIN, so you can pipe supported source files to it. I created an ...


1

I think the vim that comes with a plain Ubuntu installation lacks autocmd. Install vim completely with sudo apt-get install vim and you should be set.


1

Does putting the following in ~/.vimrc help? filetype plugin on


1

The most complete and up to date syntax hilighters for nano are maintained here. To install all highlighters for your user just run: cd /tmp git clone https://github.com/tech4david/nano-highlight.git cd nano-highlight/ make install echo "include ~/.nano/syntax/ALL.nanorc" >> ~/.nanorc


1

wget -r -nH --cut-dirs=3 --no-parent --reject="index.html*" https://nanosyntax.googlecode.com/svn/trunk/syntax-nanorc/ -P ~/.nano-syntax for i in `ls --color=never -1 ~/.nano-syntax/*.nanorc` ; do echo "include $i" >> ~/.nanorc ; done


1

I assume you are talking about gedit (labeled as "text editor" in the ubuntu menu). Gedit is using GtkSourceView for syntax highlighting. You have to create a language definition for GtkSourceView. Here is a tutorial: https://developer.gnome.org/gtksourceview/stable/lang-tutorial.html


1

I don't know of an existing highlight for C# in Nano but you could write your own. The syntax for syntax highlighting is pretty simple. Here's the one for Java (which will be very similar to a C# syntax - mainly just different keywords): ## Here is an example for Java. ## syntax "java" "\.java$" color green "\<(boolean|byte|char|double|float|int|long|new|...



Only top voted, non community-wiki answers of a minimum length are eligible