media file explorer download upload index folder image licenses menu widget Play Pause profile-settings more dots-two-horizontal dots-two-vertical more-vertical pending google-plus hangouts facebook instagram whatsapp spotify telegram twitter vine renren rss youtube twitch vimeo flickr dribble behance deviantart 500px steam github soundcloud skype reddit linkedin lastfm delicious stackoverflow pinterest xing flattr foursquare yelp World

How To Configure and Enable Syntax Highlighting in Nano Text Editor

nano is one of the most popular, and friendly editor in GNU/Linux, it has several features that can boost the usability and easiness of the program.

In the guide, you'll learn how to configure and enable syntax highlighting in nano. This way you can enable predefined syntax highlighting for programming languages, e.g Perl, Bash, Python, C, even CSS and loads more.

There are two ways to go about the configuration, you can either do a user-specific configuration where a certain user only has that specific configuration, I'll show you how to do that in a moment or do a system-wide configuration where all your user has access to the same configuration, this is done in the /etc/nanorc file.

To do a user-specific configuration of Nano text editor, you create .nanorc in the user home directory:

touch ~/.nanorc

This would create and open the .nanorc in your user home directory. The highlighting definitions are kept inside the /usr/share/nano/ directory, and their file names corresponding to each language. Run ls /usr/share/nano/ to view the available styles:

1. Syntax Highlight Styles

To add the syntax highlighting, open up the nanorc file: nano .nanorc

Include your preferred syntax file, e.g to add bash, I'll do:

include "/usr/share/nano/sh.nanorc"

Go ahead and include other option. e.g PHP or Perl or whatever programming language you are working with.