Skip to content

Feature Request: Edit Obsidian Code Blocks in CodeSpace Editor #32

Description

@WallyWilly

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:

  1. Detect the current code block.

  2. Open its contents in the existing CodeSpace editor.

  3. Allow editing in either:

    • a new tab, or
    • the current tab (depending on user preference).
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions