How to get sytax highlighting in nano for .gmi files
Nano is my editor of choice, I never weighed into the religious wars of Vim and Emacs. It does exactly what I want and need and I've used it for a couple of decades, so muscle memory would be hard to change now.
To get syntax hightlighting working in Nano, you only need to make a couple of changes.
- Edit your .nanorc file
- Add a line to the root nano area
Making the changes
- Open .nanorc in your home directory and add the following line
- include /usr/share/nano/gemini.nanorc
- Save with ctrl + o
Now to populate the gemini.nanorc in the file we just referenced
- sudo nano include /usr/share/nano/gemini.nanorc
- copy the following lines into gemini.nanorc
## syntax highlighting for gemini:// markup language syntax gemini "\.(gemini|gmi)$" # Heading levels color brightgreen "^#.*" color brightcyan "^##.*" color brightmagenta "^###.*" # Link Text color brightred "^=>\s*\S+\s+.*" # Link URL color green "^=>\s*\S+" # Link Prefix color yellow "^=>" # Bullet Lists color brightblue "^\*.*" # Monospaced Blocks color white,black start="^```" end="^```"
Save with ctrl + o
Adding some colour
Now you can create and edit .gmi files on your local or remote system using nano; with syntax highlighting. Customize it to your liking in /usr/share/nano/gemini.nanorc if you prefer.
It's not a massive change but a very useful one for me and hopefully this gemlog will help someone else out there.
Screenshots
/gemlog/