facebook youtube pinterest twitter reddit whatsapp instagram

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.

Related Post(s)

  • Installing and Running Rclone Mount As a Windows Service

    I previously wrote a guide on how to mount and unmount rclone in Linux, in this guide, I’ll walk you through on how to do the same on a windows system. Step 1: Download Rclone First, go to rclone d

  • Mounting and Unmounting Cloud Storage With (Rclone) in GNU/Linux

    Ever wondered if you could mount your preferred cloud storage as a virtual drive on your system? Thanks to Rclone, you can mount and access different kinds of cloud storage from a file manager, I'll

  • Access A Web Page In GNU/Linux Using (Links) [Web Browser in Text Mode]

    Links is a text-mode World Wide Web (WWW) browses that can be used to view a web page either via a local (file://) or remote ((http:// or ftp://) URLs. To get started with Links, install it using the

  • Installing and Using NCDU (NCurses Disk Usage)

    ncdu is a curses-based version of the well-known 'du' command and provides a fast way to see what directories are using your disk space. What I love about this utility is that it can traverse the re

  • Installing and Using dig in Ubuntu

    dig is an awesome utility for querying DNS name servers. It performs DNS lookups and displays the answers that are returned from the name server(s) that were queried. In this guide, you'll learn how

  • Installing and Configuring Nginx

    Nginx or engine X is a free and open-source web server, reverse proxying, load balancer, caching, and more. Apache isn't the only web server for hosting web content (although, it is the most used), N