Summary
Add a command that allows opening and editing an Obsidian code block directly in the CodeSpace editor, then synchronizing the changes back to the original note.
Motivation
CodeSpace provides a much better editing experience than the standard Markdown code block editor, especially for large code snippets. However, many users intentionally keep code embedded in their notes instead of storing it in separate files.
Currently, to benefit from CodeSpace's editor, code must be moved to a dedicated file, which breaks some note-taking workflows.
Proposed Solution
Add a command such as:
Open current code block in CodeSpace
Edit code block with CodeSpace
When executed while the cursor is inside a Markdown code block:
-
Detect the current code block.
-
Open its contents in the existing CodeSpace editor.
-
Allow editing in either:
- a new tab, or
- the current tab (depending on user preference).
-
When the editor is closed or saved, update the original code block content inside the note.
Example Workflow
Given the following note:
def very_long_function():
...
The user places the cursor inside the code block and runs the command.
CodeSpace opens with the block contents loaded into its editor. After editing and saving, the code block in the note is automatically updated.
Benefits
- Keeps code embedded in notes when desired.
- Improves editing of large code blocks.
- Reuses the existing CodeSpace editor instead of requiring external files.
- Provides a smoother workflow for users who mix documentation and code in the same note.
Additional Considerations
- Support language detection from the Markdown fence (e.g.,
python, javascript).
- Allow configuration for opening in a new tab or the current tab.
- Preserve formatting and code fence metadata when writing changes back to the note.
Summary
Add a command that allows opening and editing an Obsidian code block directly in the CodeSpace editor, then synchronizing the changes back to the original note.
Motivation
CodeSpace provides a much better editing experience than the standard Markdown code block editor, especially for large code snippets. However, many users intentionally keep code embedded in their notes instead of storing it in separate files.
Currently, to benefit from CodeSpace's editor, code must be moved to a dedicated file, which breaks some note-taking workflows.
Proposed Solution
Add a command such as:
Open current code block in CodeSpaceEdit code block with CodeSpaceWhen executed while the cursor is inside a Markdown code block:
Detect the current code block.
Open its contents in the existing CodeSpace editor.
Allow editing in either:
When the editor is closed or saved, update the original code block content inside the note.
Example Workflow
Given the following note:
The user places the cursor inside the code block and runs the command.
CodeSpace opens with the block contents loaded into its editor. After editing and saving, the code block in the note is automatically updated.
Benefits
Additional Considerations
python,javascript).