Syntax highlight in nano

42 views
Skip to first unread message

Pavel Yermolenko

unread,
Sep 4, 2020, 10:35:23 AM9/4/20
to BeagleBoard
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.

Pavel Yermolenko

unread,
Sep 7, 2020, 7:41:44 AM9/7/20
to BeagleBoard
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

Pavel Yermolenko

unread,
Sep 7, 2020, 9:02:32 AM9/7/20
to BeagleBoard
BTW, the vim editor does not provide syntax highlighting either.

jose...@gmail.com

unread,
Sep 7, 2020, 10:19:58 AM9/7/20
to BeagleBoard
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

Pavel Yermolenko

unread,
Sep 8, 2020, 3:38:06 AM9/8/20
to BeagleBoard
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

jose...@gmail.com

unread,
Sep 8, 2020, 4:40:15 AM9/8/20
to BeagleBoard
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.

Pavel Yermolenko

unread,
Sep 8, 2020, 5:00:29 AM9/8/20
to BeagleBoard
Yes the absence of colors is only when using serial terminal.
With ssh it's Ok, both in vim and nano.
Thanks !

jonnymo

unread,
Sep 8, 2020, 11:01:02 AM9/8/20
to Beagle Board
I usually put the .vimrc under my user folder.
Ex:
   touch ~/.vimrc

Then edit it there.

Cheers,

Jon

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/45475f10-e248-4381-aa70-ff532e2993d5o%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages