Syntax highlight in nano

Hello,

How to add syntax highlighting in nano ?
I created file .nanorc and added there

include /usr/share/nano/java.nanorc

But it didn’t work.
Thanks.

In the file /etc/nanorc there is following line:

To include all existing syntax definitions, you can do:

include “/usr/share/nano/*.nanorc”

Here is the content of /usr/share/nano/:

debian@beaglebone:~$ ls /usr/share/nano/ -l
total 180
-rw-r–r-- 1 root root 882 Jun 12 2019 asm.nanorc
-rw-r–r-- 1 root root 555 Jun 12 2019 autoconf.nanorc
-rw-r–r-- 1 root root 1342 Jun 12 2019 awk.nanorc
-rw-r–r-- 1 root root 712 Jun 12 2019 changelog.nanorc
-rw-r–r-- 1 root root 788 Jun 12 2019 cmake.nanorc
-rw-r–r-- 1 root root 1748 Jun 12 2019 c.nanorc
-rw-r–r-- 1 root root 344 Jun 12 2019 css.nanorc
-rw-r–r-- 1 root root 757 Jun 12 2019 debian.nanorc
-rw-r–r-- 1 root root 414 Jun 12 2019 default.nanorc
-rw-r–r-- 1 root root 1108 Jun 12 2019 elisp.nanorc
-rw-r–r-- 1 root root 1967 Jun 12 2019 fortran.nanorc
-rw-r–r-- 1 root root 4226 Jun 12 2019 gentoo.nanorc
-rw-r–r-- 1 root root 1317 Jun 12 2019 go.nanorc
-rw-r–r-- 1 root root 710 Jun 12 2019 groff.nanorc
-rw-r–r-- 1 root root 587 Jun 12 2019 guile.nanorc
-rw-r–r-- 1 root root 1211 Jun 12 2019 html.nanorc
-rw-r–r-- 1 root root 653 Jun 12 2019 java.nanorc
-rw-r–r-- 1 root root 763 Jun 12 2019 javascript.nanorc
-rw-r–r-- 1 root root 878 Jun 12 2019 json.nanorc
-rw-r–r-- 1 root root 2459 Jun 12 2019 lua.nanorc
-rw-r–r-- 1 root root 535 Jun 12 2019 makefile.nanorc
-rw-r–r-- 1 root root 453 Jun 12 2019 man.nanorc
-rw-r–r-- 1 root root 198 Jun 12 2019 mgp.nanorc
-rw-r–r-- 1 root root 185 Jun 12 2019 mutt.nanorc
-rw-r–r-- 1 root root 388 Jun 12 2019 nanohelp.nanorc
-rw-r–r-- 1 root root 2675 Jun 12 2019 nanorc.nanorc
-rw-r–r-- 1 root root 791 Jun 12 2019 nftables.nanorc
-rw-r–r-- 1 root root 1696 Jun 12 2019 objc.nanorc
-rw-r–r-- 1 root root 859 Jun 12 2019 ocaml.nanorc
-rw-r–r-- 1 root root 590 Jun 12 2019 patch.nanorc
-rw-r–r-- 1 root root 1457 Jun 12 2019 perl.nanorc
-rw-r–r-- 1 root root 1070 Jun 12 2019 php.nanorc
-rw-r–r-- 1 root root 919 Jun 12 2019 po.nanorc
-rw-r–r-- 1 root root 3046 Jun 12 2019 postgresql.nanorc
-rw-r–r-- 1 root root 632 Jun 12 2019 pov.nanorc
-rw-r–r-- 1 root root 1199 Jun 12 2019 python.nanorc
-rw-r–r-- 1 root root 1506 Jun 12 2019 ruby.nanorc
-rw-r–r-- 1 root root 1116 Jun 12 2019 rust.nanorc
-rw-r–r-- 1 root root 1489 Jun 12 2019 sh.nanorc
-rw-r–r-- 1 root root 1924 Jun 12 2019 spec.nanorc
-rw-r–r-- 1 root root 2181 Jun 12 2019 tcl.nanorc
-rw-r–r-- 1 root root 463 Jun 12 2019 texinfo.nanorc
-rw-r–r-- 1 root root 200 Jun 12 2019 tex.nanorc
-rw-r–r-- 1 root root 527 Jun 12 2019 xml.nanorc
debian@beaglebone:~$

But there is no syntax coloring for any of languages.
Where is the problem ?
Thanks

BTW, the vim editor does not provide syntax highlighting either.

If you provide appropriate config, vim will give you syntax highlight.
I always add in my boards the following config in /etc/vim/vimrc.local:

let g:skip_defaults_vim = 1
syntax on
set background=dark
set modeline
set modelines=3
set mouse=

BR,
José Gonçalves

A segunda-feira, 7 de setembro de 2020 à(s) 14:02:32 UTC+1, py.o…@sunrise.ch escreveu:

Thanks.

I edited /etc/vim/vimrc.
Here is what I get.
Where are colors in this so-called highlighting.
Regards,
Pavel.

Screenshot from 2020-09-08 09-34-18.png

Have you installed the full vim version ?

$ sudo apt install vim

By default, some Debian images only have installed the vim-tiny package, that does not have support to syntax highlight.

Other thing that may affect the presentation of color is the usage of a serial terminal.
If you can, login via SSH to test if, in this way, you get colors on your terminal.

A terça-feira, 8 de setembro de 2020 à(s) 08:38:06 UTC+1, py.o…@sunrise.ch escreveu:

Yes the absence of colors is only when using serial terminal.
With ssh it’s Ok, both in vim and nano.
Thanks !

I usually put the .vimrc under my user folder.
Ex:
touch ~/.vimrc

Then edit it there.

Cheers,

Jon