When inspecting multi-megabyte CNC toolpaths (G-code for Fanuc/Siemens 840D) or ASCII DXF drawing files in Sublime Text, heavy regular expressions in custom syntax definitions can quickly introduce UI latency or high memory overhead.
Here are a few practical optimizations we implement for high-throughput engineering text inspection:
- Eliminating Backtracking in Syntax Definitions:
In.sublime-syntax, avoid open-ended quantified groups like.*inside toolpath comment matchers. Instead, use atomic lookaheads or negative character classes:
- match: '\([A-Z0-9_\-\s]{1,60}\)'
scope: comment.line.parentheses.gcode
- Optimizing Modal G/M Code Scopes:
For modal groups (G00,G01,G02,G03,G54…G59), avoid deep scope stacks. Keep scopes shallow so the text layout engine does not construct excessive styling boundaries:
- match: '\b(G0?[0-3]|G5[4-9])\b'
scope: keyword.control.motion.gcode
- match: '\b(M0?[3-9]|M30)\b'
scope: keyword.operator.auxiliary.gcode
- Buffer Configuration for Massive DXF Dumps:
Add the following project-level settings to prevent indexing spikes during multi-part DXF diffing:
{
"index_exclude_patterns": ["*.dxf", "*.nc", "*.tap", "*.gcode"],
"binary_max_size": 104857600,
"show_line_endings": false
}
These adjustments allow instant multi-cursor editing across 500,000+ line machine files without frame drops.