If you like programming in the console, it'll be handy to have syntax highlighting
in your favorite editor. Vi
are the most used editors, so i'll show how to turn on syntax highlighting for these editors.
Edit the vimrc
file, it's in the home dir
Edit the syntax line to what it says below, or add this line to the file if it doesn't exist:
Syntax highlighting is now turned on for the languages Vi supports highlighting with.
The process of turning on syntax highlighting on Nano is a bit different, the integration of syntax highlighting in the editor is not that great, certainly not equal to that of an editor like Vi.
Edit the nanorc
file, it's in /etc
Go to the syntax section in the file (you can search for "syntax", though in my nanorc file the section is at line 215). You'll see something like the following:
# include "/usr/share/nano/c.nanorc"
# include "/usr/share/nano/html.nanorc"
# include "/usr/share/nano/perl.nanorc"
# include "/usr/share/nano/python.nanorc"
# include "/usr/share/nano/ruby.nanorc"
# include "/usr/share/nano/java.nanorc"
# include "/usr/share/nano/asm.nanorc"
## Bourne shell scripts
# include "/usr/share/nano/sh.nanorc"
You can simply uncomment the file includes for the languages you want syntax highlighting enabled on.
The number of languages Nano offers syntax highlighting for is limited. If you think Vi is too complicated, and Nano doesn't support the language(s) you program in, you can always use Joe
, it has by default regex files for syntax highlighting, and for more languages than Nano.