Skip to content

GCode Editor

Marius Stanciu edited this page Oct 29, 2026 · 1 revision

The GCode Editor changes the G-Code of a CNCJob Object. You edit the text, insert code snippets, and then save the change to the object or export the text to a file. The text editor (the same editor type) also runs in Script Objects and Document Objects. Those objects have their own pages: Script-Object and Document-Object.

Where to find it

  • Select a CNCJob Object in the Project tree. Then select Edit > Edit Object (shortcut E). The GCode Editor button in the object panel also starts the editor.
  • The editor opens in the plot area as the Code Editor tab. Its controls show in the Properties tab, under the title GCode Editor.
  • Exit the editor with the Exit Editor button, the Ctrl+S shortcut, or the Exit Editor item of the editor context menu.
  • The shortcut Ctrl+S works only while the GCode Editor is the active editor.

Screenshot placeholder: images/GCode-Editor-1.png — the Code Editor tab in the plot area, with the Properties panel showing the GCode Editor title, the Name: box, the CNC tools table and the Exit Editor button.

Quick start

  1. Select a CNCJob Object in the Project panel.
  2. Open the G-Code in the Code Editor tab.
  3. Click the Advanced button to show the CNC Code Snippet boxes. Skip this step for the Beginner mode.
  4. Place the text cursor in the code. Click Insert Code to add a snippet at the cursor.
  5. Edit the code in the text area.
  6. Click Exit Editor. In the dialog, click Yes to save the changes to the object. Click No to discard them. Click Cancel to stay in the editor.
  7. Optional: click Save in the editor toolbar to write the text to a file. This does not update the object.

Parameters

Title area

Parameter Description Default
GCode Editor (title) The name of the editor. It is a label, not a control. —
Level button (Beginner / Advanced) Switches the editor between the two modes. Beginner hides the CNC Code Snippet section. Advanced shows it. The text shows the current mode. Green is Beginner, red is Advanced. The tooltip says that a permanent change is done in the Preferences menu. Beginner (global_app_level = 'b')

Screenshot placeholder: images/GCode-Editor-2.png — the level button in both states, Beginner (green) and Advanced (red).

Name

Parameter Description Default
Name: The name of the edited object. Press Enter in the box to call the name handler. The name of the CNCJob Object

CNC tools table

The table shows for the CNCJob Objects made from a Geometry or Gerber source. The Excellon table shows for the CNCJob Objects made from an Excellon source. Only one table shows at a time. Select a row to select the matching block of G-Code text in the editor.

Parameter Description Default
# The tool number. —
GCode The G-Code block of the row. The rows are All, Header, Start, and one row for each tool. —
Offset The offset value of the tool block. —
Job The job type of the tool block. The choices are Roughing, Finishing, Isolation and Polishing. —
Shape The shape of the tool block. —

Excellon table columns: #, GCode, Drills, Slots, Cut Z. The rows are All GCode, Header GCode and Start GCode.

CNC Code Snippet (visible in Advanced mode only)

Parameter Description Default
CNC Code Snippet 1: text area Text to insert at the cursor. The placeholder text reads: "Type here any G-Code commands you would like to insert at the cursor location." The tooltip says that the snippet is defined in Preferences. Empty (cncjob_prepend = "")
Insert Code (first button) Inserts the text of the first snippet at the text cursor. A new line is added after the text. —
CNC Code Snippet 2: text area Second snippet. Same behavior as the first one. Empty (cncjob_append = "")
Insert Code (second button) Inserts the text of the second snippet at the text cursor. A new line is added after the text. —

Screenshot placeholder: images/GCode-Editor-3.png — the CNC Code Snippet section in Advanced mode, with both text areas and both Insert Code buttons.

Exit Editor

Parameter Description Default
Exit Editor (button) Opens the exit dialog. The tooltip reads: "Exit from Editor." The button is bold and has a power icon. It exits with the same dialog as Ctrl+S. —

Editor toolbar (text editor controls)

The editor has a row of controls under the text area. The GCode Editor uses these controls:

Parameter Description Default
Find (button) Searches for the text in the Find box. It highlights all matches in yellow. —
Find box The text to search for. Press Enter to run Find. The search is case sensitive. Empty
Replace With (button) Replaces the text in the Find box. See the rules below. —
Replace box The new text. Empty
All (check box) When checked, Replace With replaces every match in the document. When not checked, it replaces only the selected text. Not checked
Save (icon button) Writes the text of the editor to a file. The tooltip reads: "Will save the text in the editor into a file." The button turns red when the text changed. —
Open (icon button) Loads a text file into the editor. The text replaces the current text. —
Print (icon button) Opens the operating system Print window. The tooltip reads: "Open a OS standard Print window." —
Preview (icon button) Opens the operating system Print Preview window. —

The Run button and the Save changes internally button are hidden in the GCode Editor.

Find and Replace rules

  • Find searches from the cursor position. If no match is found, a message box asks Start from beginning? with the buttons Ok and Cancel. Ok starts the search at the start of the document.
  • Replace With with All checked: replaces every match in the whole document in one step. One Undo removes all the replacements.
  • Replace With with All not checked: replaces the selected text only. If no text is selected, nothing changes.

Screenshot placeholder: images/GCode-Editor-4.png — the find and replace bar with a highlighted match, the All check box, and the "Start from beginning?" message box.

Save and exit dialog

When you click Exit Editor, or press Ctrl+S, this dialog opens. Its title is Exit Editor. Its question is Do you want to save the changes?

Button Description
Yes Saves the edited G-Code to the CNCJob Object. The editor closes. The message reads "Editor exited. Editor content saved."
No Closes the editor without saving. The message reads "Editor exited. Editor content was not saved."
Cancel Stays in the editor.

Screenshot placeholder: images/GCode-Editor-5.png — the Exit Editor dialog with the buttons Yes, No and Cancel.

Advanced

Exit dialog by control

  • The Exit Editor button and Ctrl+S open the dialog with the buttons Yes, No and Cancel.
  • The Exit Editor item of the canvas right-click menu opens the dialog with the buttons Yes and No only. Use the button or Ctrl+S to keep the editor open with Cancel.
  • A CNCJob Object does not offer Save as New. The save button therefore has the label Yes.

Where the changes go

  • Yes rewrites the G-Code of the CNCJob Object with the editor text. The object rebuilds its Properties page. The editor tab closes.
  • Save (toolbar) writes the text to a file. The object is not changed. The file name uses the Export Code ... dialog. The default file types are G-Code files (*.nc, *.txt, *.tap, *.cnc), PDF files (*.pdf) and all files.
  • If the file name ends in .pdf, the text is written as a PDF. The page margins come from the Preferences (global_tpdf_*).
  • Open in the GCode Editor replaces the text in the editor. The object does not change until you exit with Yes.

Text editor (Script and Document objects)

The text editor is the same editor widget used by Script Objects and Document Objects. The same controls exist, with these differences:

  • The Run button shows for Script Objects only. It runs the TCL commands in the text, one by one. See Script-Object.
  • The Document Object hides the Run button. See Document-Object.
  • Open and Save in a Script Object use the file of that Script Object. The Script Object saves the text to its own file.
  • The Exit and Find/Replace controls are the same as in the GCode Editor.

Keyboard shortcuts

Key Action Scope
Ctrl+S Opens the exit dialog (Yes, No, Cancel). GCode Editor only
Enter in the Find box Runs Find. Text editor

The editor has no Ctrl+F, Ctrl+H or Ctrl+G shortcut. Use the Find box instead. See Keyboard-Shortcuts for the full list.

Line numbers

The GCode Editor shows line numbers in a gutter on the left side of the text area. The editor shows no line and column status display.

Limits

  • The GCode Editor does not offer Save as New. The changes always go to the same CNCJob Object.

Related Tcl commands

The GCode Editor has no Tcl command of its own. For the scripting features, see Tcl-Scripting and Tcl-Command-Reference.

See also

Clone this wiki locally