Search...Search plugins and themes...
⌘K
Sign in
  • Get started
  • Download
  • Pricing
  • Enterprise
  • Account
  • Obsidian
  • Overview
  • Sync
  • Publish
  • Canvas
  • Mobile
  • Web Clipper
  • CLI
  • Learn
  • Help
  • Developers
  • Changelog
  • About
  • Roadmap
  • Blog
  • Resources
  • System status
  • License overview
  • Terms of service
  • Privacy policy
  • Security
  • Community
  • Plugins
  • Themes
  • Discord
  • Forum / 中文论坛
  • Merch store
  • Brand guidelines
Follow us
DiscordTwitterBlueskyThreadsMastodonYouTubeGitHub
© 2026 Obsidian

Copy as Context

JaydonJaydon21 downloads

Copy the selected text with its note path, line numbers and heading path, or a folder as a tree, ready to paste into an AI chat or agent.

Add to Obsidian
  • Overview
  • Scorecard
  • Updates2

Select text in a note and copy it together with where it came from — the note path, line numbers and the headings it sits under — ready to paste into an AI chat or a terminal agent such as Claude Code or Codex. You can also copy a folder as a ├── / └── tree.

Copy a selection

Select some text, then use any of:

  • Right-click → Copy as context (editing view)
  • Command palette → Copy as Context: Copy selection as context
  • A hotkey you assign in Settings → Hotkeys (the plugin sets none by default)

What lands on the clipboard (Markdown format):

File: projects/launch/script.md (lines 12-20, section: Intro > Hook)
```markdown
…the selected text…
```
  • Line numbers start at 1 and match the file on disk, frontmatter included, so an agent can open the file at those lines.
  • With multiple cursors, each selection becomes its own block.
  • In reading view, the plugin finds the blocks (paragraphs, lists, headings…) your selection touches and copies their original Markdown with exact line numbers, instead of the rendered text with its formatting stripped. This also works when the same sentence appears more than once in the note.

Copy a folder tree

Right-click a folder in the file explorer → Copy folder tree:

Folder: projects/launch
```text
launch/
├── footage/
│   ├── clip2.mp4
│   └── clip10.mp4
├── notes.md
└── script.md
```

Folders come first and end with /. Big folders such as node_modules can be left out with the Exclude setting.

Settings

Setting Options Default
Output format Markdown (code fence), XML (<file> / <tree> tag), plain text (header line only) Markdown
Path Relative to the vault, or absolute Relative
Include heading path Add the headings the selection sits under On
Folder tree → Exclude One pattern per line. Without a slash it matches a name anywhere (node_modules, *.log); with a slash it matches the path from the vault root (Archive/, projects/old) node_modules

Install

From Obsidian: Settings → Community plugins → Browse, search for “Copy as Context”.

Manually: download main.js and manifest.json from the latest release into <vault>/.obsidian/plugins/copy-as-context/, then enable the plugin under Settings → Community plugins.

Development

npm install
npm test          # unit tests for formatting and tree logic
npm run build     # type-check and bundle main.js
npm run install-plugin -- /path/to/vault   # copy main.js and manifest.json into a vault

License

MIT

HealthExcellent
ReviewPassed
About
Copy selected text together with its source — file path, exact line numbers and enclosing headings — formatted for pasting into AI chats or terminal agents. Copy folder trees as an ASCII ├──/└── tree and copy from reading view as original Markdown blocks, preserving multiple selections and exact line numbers.
AIFilesMarkdown
Details
Current version
0.1.1
Last updated
2 days ago
Created
3 days ago
Updates
2 releases
Downloads
21
Compatible with
Obsidian 1.4.0+
Platforms
Desktop, Mobile
License
MIT
Report bugRequest featureReport plugin
Author
JaydonJaydonjaydonzhao
GitHubjaydonzhao
  1. Community
  2. Plugins
  3. AI
  4. Copy as Context

Related plugins

Claudian

Embeds Claude Code/Codex and other local Agents as AI collaborators in your vault.

ChatGPT MD

A seamless integration of ChatGPT, OpenRouter.ai and local LLMs via Ollama into your notes.

Gemini Scribe

Allows you to interact with Gemini and use your notes as context.

Notebook Navigator

A better file browser and calendar inspired by Apple Notes, Bear, Evernote and Day One.

Text Format

Format selected text upper/lower/capitalize.

Linter

Format and style your notes. Linter can be used to format YAML tags, aliases, arrays, and metadata; footnotes; headings; spacing; math blocks; regular Markdown contents like list, italics, and bold styles; and more with the use of custom rule options.

Smart Connections

Find related notes and excerpts while writing. Your AI link building copilot displays relevant content in graph + list view. A local embedding model powers semantic search. Zero setup. No API key.

Advanced URI

Control everything with URI.

Fast Note Sync

Real-time sync of your vaults across server, mobile, and web; shareable with anyone; supports REST and MCP integrations to build your personal AI knowledge base.

Thino

Quickly capture memos and display them in the sidebar with a heatmap. (Closed source)