Skip to content

Creating And Editing Gists

Grisgram edited this page Jun 25, 2026 · 1 revision

Creating a New Gist

There are two primary workflows for capturing code into the GDGist ecosystem:

1. From the GDGist Dock

Right-click anywhere within the GDGist custom tree dock and select Create Gist. This will initialize an empty snippet definition. If you right-click a specific folder, the new gist will automatically inherit that folder's path.

  • Community Edition: Gists are saved to your project-local .gdgist directory.
  • Pro Edition: You have the option to save Gists to the Global root folder, persisting the snippet to your OS user data directory for cross-project availability.

2. From the Code Editor (Selection Capture)

For rapid extraction of existing boilerplate, highlight any block of text directly inside the Godot script editor, right-click the selection, and choose Create Gist from Selection from the context menu. This immediately opens the Gist Editor with the selected code pre-populated.

image

The Gist Editor

Whether creating a new snippet or double-clicking an existing one in the dock, the Gist Editor dialog is your interface for configuring snippet behavior.

image

Gist Scope and Inheritance

The true power of GDGist lies in its contextual awareness. The Inherits field in the Gist Editor defines the GDScript base class to which this snippet applies (e.g., Node, CharacterBody3D, Control).

When you invoke the RAlt+. insertion menu in a script, GDGist parses the current script's extends class. It then recursively walks up the inheritance tree to display only relevant snippets.

  • Example: A snippet scoped to Node3D will appear in the insertion menu for a CharacterBody3D script, but it will not appear if you are editing a Control UI script.
  • Leave the scope blank to make the snippet universally available.

Syntax Sugar: Selection Markers

GDGist supports intelligent cursor placement post-insertion. By wrapping text in the snippet definition with exclamation-brackets !> and <!, you instruct the Godot script editor to automatically highlight that text immediately after the snippet is inserted. This allows you to instantly type over placeholder variable names without reaching for the mouse.

# In the Gist Editor:
var !>state_name<! : State = State.new()

When inserted, state_name is selected and ready for immediate replacement:
image

Unrestricted File Size (Class Templating)

GDGist imposes no artificial character limits on your snippets. Because of this, veteran developers frequently use the tool as a centralized alternative to Godot's built-in Script Templates system. You can define massive, 500-line State Machine base classes, Interface definitions, or complex EditorPlugin bootstraps and deploy them instantly via the Alt+. menu.


Architectural Use-Cases

To maximize the efficiency of your snippet library, consider these common implementations:

Overriding Virtual Functions

Store your preferred boilerplate for standard virtual overrides, complete with super() calls where architecturally necessary.

func _ready() -> void:
	# Ensure base class initialization
	super()
	!>pass<!

Standardized Logging (Recurring Templates)

Maintain project-wide uniformity for console output. Instead of typing print() manually, define strictly formatted log blocks.

push_error("[ERROR]: !>error_message<!")
push_warning("[WARNING]: !>warning_message<!")

Clone this wiki locally