G Code Syntax in Nano
Get basic g code syntax highlighting in nano text editor.
I use a small Linux file server to store and backup all G-Code we run. Its handy to be able to pull it up on the file share and review it before pulling it down to one of the machines in the shop.
As the file server is not running a desktop, its command line only and i SSH into it I use nano to review and edit the files from time to time. I wanted basic syntax highlighting for the G-Code and spent a few minutes writing a basic syntax rule set.
Nano stores settings an syntax in several ways. I describe the simplest here.
we need to create or modify the nanorc file locate in ~/.config/nano/
~/.config/nano/nanorc
In this file we need to add the following rules:
syntax "Gcode" "\.(mpf|cnc|tap|nc)$"
#Line numbers
color gray "N[^ )]+"
#Tools
color brightyellow "T[^ )]+"
color brightyellow "D[0-9]+"
color yellow "S[^ )]+"
#G-codes
color brightgreen "G[^ )]+"
color green "F[^ )]+"
#M-codes
color brightmagenta "M[^ )]+"
#Comments
color blue "[;].+"
Save your changes and the use Nano to edit an *.nc file. The document will have basic syntax color making it easy to see comments, G, M, and other code in the document.
Here is a simple example looking at a Siemens Sinumerik .mpf G-Code document.
Comments ()