Pascal syntax highlighting in Nano

I have placed to my /usr/share/nano folder, hoping that my Pascal source code would then be syntax-highlighted by Nano. But, Nano has never able to do so. Have I missed something?

P.S.: No error code is generated when I open a .pas file. I use fpc as compiler.

Create a file in your home


include /usr/share/nano/*.nanorc
include ~/.config/nano/*.nanorc

Then copy put your syntax file in ~/.config/nano

NOTE: Manually copying files to system folders has the possibility to create file conflicts for pacman at a later time.

Also checkout:

  • man nanorc look for include "syntaxfile"
    When trying to find something in the man pages, try, in this case, man -k nano.
  • /etc/nanorc found via locate 'nanorc'

I currently put my nano usr configuration file in $HOME/.config/nano/nanorc.

A syntax file can be inline or included.


The snippet below is part of my nanorc file with an inline highlighting file. I could have easily done include './asciidoc.nanorc' if I had put it in the directory $HOME/.config/nano/

### Simple asciidoc highlighting
syntax "AsciiDoc" "\.(txt|asc)$"
header "^={1,2}[[:space:]]+.+[[:space:]]+={1,2}$"
# h1
color black,white "^=[[:space:]]+.+[[:space:]]+=$"
# h2
color red "^==[[:space:]]+.+[[:space:]]+==$"
# h3
color red "^===[[:space:]]+.+[[:space:]]+===$"
# .title
color blue "^\.[^[:space:].]+.+$"

Thank you for your quick reply. I forgot to mention that I have already set include /usr/share/nano/*.nanorc in my nano configuration file. It works straight away for other “built-in” syntaxes like c, fortran and python. At some point, I then realized that actually the original file delphi.nanorc was insufficiently configured. By, adding some proper pascal syntax highlighting rules to the original delphi.nanorc, it is now working properly as I intended.

I must say big thank you. Looking at your sample asciidoc.nanorc, I finally figured out what was wrong with my delphi.nanorc file.

What was it :slight_smile:

It lacked proper syntax, such as color brightmagenta "\<(and|div|mod|or)\>". Those kind of syntax is what I need for syntax-highlighting my pascal code. Sorry for my slow respones.