help-nano
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

selecting a syntax by the file's first line


From: Benno Schulenberg
Subject: selecting a syntax by the file's first line
Date: Sat, 1 Aug 2020 19:40:59 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0

Hello Sébastien,

>> When nano does not apply the correct syntax to a file, one could do either:
>> 2) add or modify the first line so that nano recognizes it,
> 
> I am quite interested by this: most often, my Perl scripts do not have a name
> that ends in .pl so the following lines in my ~/.nanorc do not apply:
>     syntax perl "\.(html|mas|pl)$"
>     comment "#"
>     color brightblack "#.*"
> 
> Could you give an example of how I could tell Nano that files starting with
> #!/usr/bin/perl are to use some syntax-hilighting scheme? A pointer to the
> relevant part of the Doc would be just as good :-)

Open 'info nano' or 'man nanorc' and search for "header" (without the quotes).

Or simply do:  grep header syntax/perl.nanorc

You can make the header line more specific, if you like.  For example:

  header "^#!(/usr)?/bin/perl$"


Note, though, that if your file name matches any of the file regexes in
your nanorc files, that thát match takes precedence.

Regards,

Benno

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]