Can nano do syntax highlighting like gedit and vim? How can I enable it? I need at least bash and python syntax highlights.
|
|
The nano editor provides syntax highlighting for a few languages and scripts by itself. Check out
Link them to your user's nano configuration file present at
Now, syntax highlighting is enabled in nano for whatever file you linked (You could also link multiple files)
Note: Sometimes you might get a There are also other solutions if you are not satisfied with your bash highlighting. One example of such can be found here You can also write |
|||||||||||||||||||||
|
|
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:
Add these lines to the ~/.nanorc
Specify the ones you want to have colorizing for, and you will have to tune these colors to your preferences. The |
|||||||||||||||||||||
|
|
I used this command to quickly enable all available languages.
As mentioned in other answers,
Also mentioned, to enable highlighting for a language, you add
The
|
|||||
|
|
This should include all the syntax highlighting plugins included by default, and any you add to /usr/share/nano:
Or, edit /etc/nanorc and see if you can uncomment the includes. This works if you have a version of nano that refuses to accept wildcards in the .nanorc file. Just run this line every time you add an additional .nanorc colour config. |
||||
|
|
|
I have some nano syntax highlighting at my github. There are live example screenshots for html and php:
and
|
||||
|
|
|
|||||
|
|
The most complete and up to date syntax hilighters for nano are maintained here. To install all highlighters for your user just run:
|
|||||||||||||
|
|
You can use this to include all: (add this to ~/nanorc file)
Happy coding ! |
|||
|
|
|
I found syntax highlighting for js here. I appended it into my user file at However to get a file into which I could append, I had to first copy from |
||||
|
|
|
I just made this script to add the colours to nano: But of course you got to have the color codes in /usr/share/nano for this to work. If there are errors: just manually edit the ~/.nanorc file and remove the lines that give the errors.
|
||||
|
|
|
For those who are having trouble after following the instructions above, also check if you have duplicate definitions. These will disable all syntax highlighting for all files. I ran into this after adding a
|
|||
|
|


