Process selected text chunks within files instead of full file operations
This skill enables processing of selected text portions within files, rather than forcing full-file rewrites. This saves tokens, reduces processing time, and allows targeted AI operations on specific sections.
Process Selection
├── Get selected text from editor
├── Get surrounding context (optional)
├── Process selected content (LLM)
├── Replace or append selected content
└── Update file
// From Obsidian editor
const editor = view.editor;
const selection = editor.getSelection();
// From VS Code
const selection = editor.selection;
const text = editor.document.getText(selection);
For better results, include surrounding context:
// Get context before and after selection
const lineNum = editor.getCursor().line;
const beforeLines = editor.getRange({line: 0, ch: 0}, {line: lineNum, ch: 0});
const afterLines = editor.getRange({line: lineNum, ch: 0}, {line: maxLine, ch: 0});
const fullContext = beforeLines + selection + afterLines;
// Replace selected text with processed result
editor.replaceSelection(processedContent);
// Or append after selection
editor.replaceRange('\n\n' + processedContent, {line: lineNum + 1, ch: 0});
// Selected: "Machine learning is a subset of AI"
// Process: Add links to key concepts
// Result: "Machine learning is a subset of [[AI]]"
async function addLinksToSelection(app: App, editor: Editor) {
const selection = editor.getSelection();
const prompt = getSystemPrompt('addLinks');
const result = await callLLM(prompt, selection);
editor.replaceSelection(result);
}
// Selected: "Neural Networks"
// Process: Generate expanded content
// Result: Full explanation of neural networks
async function generateFromSelection(app: App, editor: Editor) {
const selection = editor.getSelection();
const prompt = getSystemPrompt('generateTitle', {TITLE: selection});
const result = await callLLM(prompt, '');
editor.replaceSelection(result);
}
// Selected: Some text in English
// Process: Translate to target language
// Result: Translated text
async function translateSelection(app: App, editor: Editor, targetLang: string) {
const selection = editor.getSelection();
const prompt = getSystemPrompt('translate', {LANGUAGE: targetLang, TEXT: selection});
const result = await callLLM(prompt, '');
editor.replaceSelection(result);
}
| Setting | Description |
|---------|-------------|
| includeContextLines | Number of context lines to include |
| replaceSelection | Replace or append processed content |
| preserveFormatting | Preserve original formatting |
| Setting | Description |
|---------|-------------|
| contextBefore | Lines before selection |
| contextAfter | Lines after selection |
| includeHeadings | Include parent headings |
Empty selection
Selection too large
Invalid cursor position
// Get selection from DOM
const selection = window.getSelection().toString();
// Process with file system
const content = fs.readFileSync(filepath, 'utf-8');
// Find and replace range
# Pipe selected content to script
echo "$SELECTED_TEXT" | notemd-process --operation=links
# Output replaces stdin
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer