A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
docs: custom snippets (#3903)
Myles Scolnickf99c27053476
diff --git a/docs/guides/configuration/index.md b/docs/guides/configuration/index.mdindex bbf7f31704..f18c74f673 100644--- a/docs/guides/configuration/index.md+++ b/docs/guides/configuration/index.md@@ -42,6 +42,7 @@ You can customize the following settings:- [VIM keybindings](../editor_features/overview.md#vim-keybindings)- Formatting settings- [AI assistance](../editor_features/ai_completion.md)+- [Snippets](snippets.md)- Experimental features### User configuration filediff --git a/docs/guides/configuration/snippets.md b/docs/guides/configuration/snippets.mdnew file mode 100644index 0000000000..a24a28a571--- /dev/null+++ b/docs/guides/configuration/snippets.md@@ -0,0 +1,60 @@+# Snippets Configuration++marimo provides a snippets feature that allows you to quickly insert commonly used code blocks into your notebooks. You can configure both the default snippets and add your own custom snippets.++## Configuration Options++You can configure snippets through your `marimo.toml` file:++```toml+[snippets]+custom_paths = ["/path/to/your/snippets/dir"] # List of paths to directories containing custom snippets+include_default_snippets = true # Whether to include marimo's default snippets (defaults to true)+```++## Custom Snippets++To add your own snippets:++1. Create a directory to store your snippets+2. Add the directory path to the `custom_paths` list in your configuration+3. Create snippet files in your directory following the marimo snippet format++### Snippet Format++Snippets are Python files that follow a specific format. Each snippet should be a marimo notebook file with a title and code:++Example snippet file (`my_snippet.py`):++```python+import marimo++app = marimo.App(width="medium")+[email protected](hide_code=True)+def _(mo):+ mo.md(r"""# Load .env""")+ return+++def _():+ import dotenv++ dotenv.load_dotenv(dotenv.find_dotenv(usecwd=True))+ return (dotenv,)+++def _():+ import marimo as mo+ return (mo,)+++if __name__ == "__main__":+ app.run()+```++## Default Snippets++marimo comes with a set of default snippets for common operations. You can disable the default snippets by setting `include_default_snippets = false` in your configuration.diff --git a/mkdocs.yml b/mkdocs.ymlindex aea4f407ea..d8718532b7 100644--- a/mkdocs.yml+++ b/mkdocs.yml@@ -134,6 +134,7 @@ nav:- Runtime configuration: guides/configuration/runtime_configuration.md- HTML head: guides/configuration/html_head.md- Theming: guides/configuration/theming.md+ - Snippets: guides/configuration/snippets.md- Coming from other tools:- Coming from other tools: guides/coming_from/index.md- Jupytext: guides/coming_from/jupytext.md