Can nano do syntax highlighting like gedit and vim? How can I enable it? I need at least bash and python syntax highlights.
Ubuntu – How to enable syntax highlighting in nano
nanosyntax highlighting
nanosyntax highlighting
Can nano do syntax highlighting like gedit and vim? How can I enable it? I need at least bash and python syntax highlights.
Best Answer
The nano editor provides syntax highlighting for a few languages and scripts by itself. Check out
/usr/share/nano/
Link them to your user's nano configuration file present at
~/.nanorc
with something similiar to this line:Now, syntax highlighting is enabled in nano for whatever file you linked (You could also link multiple files)
Note: Sometimes you might get a
segmentation fault
after you have edited your~/.nanorc
file. If such an error occurs, unsetting the LANG environment variable helps. You can unset it withunset LANG
in the terminal. (Solution obtained from here)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
include /usr/share/nano/*
to the ~/.nanorc file to enable all languages to be highlighted if your nano version supports it.