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:
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:
To add the syntax highlighting, open up the nanorc file:
Include your preferred syntax file, e.g to add bash, I'll do:
Go ahead and include other option. e.g PHP or Perl or whatever programming language you are working with.