Creating script templates

Script Create Dialog while creating a new script: A set of default script templates is provided by default, but it’s also possible to modify existing and create new ones, both per project and the editor.

Locating the templates

There are two places where templates can be managed.

Editor-defined templates

These are available globally throughout any project. The location of these templates are determined per each OS:

  • %APPDATA%\Godot\script_templates\
  • $HOME/.config/godot/script_templates/
  • $HOME/Library/Application Support/Godot/script_templates/ script_templates is detected, Godot will create a default set of built-in templates automatically, so this logic can be used to reset the default templates in case you’ve accidentally overwritten them.

    Project-defined templates

    res://script_templates/ directory. The path can be changed by configuring the editor/script_templates_search_path setting in the ProjectSettings, both via code and the editor. script_templates directory is found within a project, it is simply ignored.

    Language support and overriding behavior

    gd and cs respectively. Note .gdignore file. The directory won’t be visible throughout the project’s filesystem anymore, yet the templates can be modified by an external text editor anytime. The built-in editor templates are automatically shadowed by the project-specific templates given both scripts have the same filename.

    Default template

    Default template is always generated dynamically per language and cannot be configured nor overridden, but you can use these as the base for creating other templates. GDScript C#
    1. extends %BASE%# Declare member variables here. Examples:# var a%INT_TYPE% = 2# var b%STRING_TYPE% = "text"# Called when the node enters the scene tree for the first time.func _ready()%VOID_RETURN%: pass # Replace with function body.# Called every frame. 'delta' is the elapsed time since the previous frame.#func _process(delta%FLOAT_TYPE%)%VOID_RETURN%:# pass
    1. using Godot;using System;public class %CLASS% : %BASE%{ // Declare member variables here. Examples: // private int a = 2; // private string b = "text"; // Called when the node enters the scene tree for the first time. public override void _Ready() { }// // Called every frame. 'delta' is the elapsed time since the previous frame.// public override void _Process(float delta)// {//// }}

    List of template placeholders

    The following describes the complete list of built-in template placeholders which are currently implemented.

    Base placeholders

    Type placeholders

    text_editor/completion/add_type_hints setting in the EditorSettings.