editing

Solid

文本/代码的增量编辑:通过 exec 执行 PowerShell 实现 ReadRange、ReplaceRangeWithText、ReplaceAll、InsertLines、DeleteRange 等操作。Use when: 按行号或按内容修改文件、编程时局部替换、避免整文件重写。可与 coding / csharp skill 配合。

Code & Development 39 stars 12 forks Updated 1 months ago MIT

Install

View on GitHub

Quality Score: 73/100

Stars 20%
53
Recency 20%
75
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Editing Skill(editing) 在**没有**单独「按行号读/按片段替换」工具时,用 **exec** 执行 PowerShell 完成文本编辑。所有操作均以**命令行(Shell)**实现,适合编程场景下的增量修改。 ## When to Use - 按行号替换一段内容(ReplaceRangeWithText) - 按行号只读某一段(ReadRange) - 按字面或正则整文件替换(ReplaceAll / ReplaceAllRegex) - 在指定行后插入、删除行范围、追加行 - 与 **coding**、**csharp** skill 配合:先 Grep/SemanticSearch 定位,再调用本 skill 中的方法做局部编辑 ## 约定 - **路径**:相对工作区(如 `.\src\Foo.cs`)或绝对路径;含空格时用单引号 `'...'`。 - **行号**:一律 **1-based**;PowerShell 数组 0-based,脚本内已做 `$s-1..$e-1` 转换。 - **编码**:写文件统一 `-Encoding UTF8`。 - **执行方式**:将下面任一方法的 PowerShell 片段通过 **exec** 运行,按需替换变量值。 --- ## 1. ReadRange — 只读第 S 行~第 E 行 Grep 得到行号后,只读该区间,避免 read 只读前 N 行读不到后面。 **用法**:`ReadRange(path, startLine, endLine)` → 用 exec 执行下面,输出即该范围内容。 ```powershell $path = '.\src\Foo.cs'; $s = 101; $e = 150; (Get-Content $path)[$s-1..$e-1] ``` --- ## 2. ReplaceRangeWithText — 按行号替换一段为多行文本 只改第 S 行~第 E 行,其余行不动。新内容行数可与原段不同。 **用法**:`ReplaceRangeWithText(path, startLine, endLine, newLines)`。`newLines` 为字符串数组,在 PowerShell 中写成 `@('行1','行2')`;若多行字符串则用 `"L1`nL2" -split "`n"`。 ```powershell $path = '.\src\Foo.cs'; $s = 101; $e = 110 $lines = Get-Content $path $new = @(' // 新代码行1', ' // 新代码行2') $lines[$s-1..$e-1] = $new $lines | Set-Content $path -Encoding UTF8 ``` **多行字符串示例**(一段新代码): ```powershell $path = '.\src\Foo.cs'; $s = 101; $e = 110 $lines = Get-Content $path $new = @" public void NewMethod() { return; } "@ -split "`r?`n" $lines[$s-1..$e-1] = $new $lines | Set-Content $path -Encodi...

Details

Author
LdotJdot
Repository
LdotJdot/OpenLum
Created
2 months ago
Last Updated
1 months ago
Language
JavaScript
License
MIT

Similar Skills

Semantically similar based on skill content — not just same category

AI & Automation Listed

find-replace

Modern find-and-replace using sd (simpler than sed) and batch replacement patterns. Triggers on: sd, find replace, batch replace, sed replacement, string replacement, rename.

16 Updated 1 months ago
0xDarkMatter
Data & Documents Solid

content-pipeline

内容生产和分发统一管线。素材收集→出稿→排版→封面→朋友圈文案→多平台转换→一键分发。涵盖公众号写作、小红书轮播图、即刻文案、播客音频、品牌视频、Chrome CDP 自动发布。

169 Updated 1 months ago
OrangeViolin
Code & Development Solid

code-refactor

Perform bulk code refactoring operations like renaming variables/functions across files, replacing patterns, and updating API calls. Use when users request renaming identifiers, replacing deprecated code patterns, updating method calls, or making consistent changes across multiple locations.

585 Updated 2 months ago
mhattingpete
Data & Documents Solid

bruce-doc-converter

双向文档转换工具,将 Word (.docx)、Excel (.xlsx)、PowerPoint (.pptx) 和 PDF (.pdf) 转换为 AI 友好的 Markdown 格式,或将 Markdown (.md) 转换为 Word (.docx) 格式。当用户请求以下操作时使用:(1) 明确请求文档转换,包括任何包含"转换"、"转为"、"转成"、"convert"、"导出"、"export"等词汇的请求(例如:"转换文档"、"把这个文件转为docx"、"convert to markdown"、"导出为Word");(2) 需要 AI 理解文档内容("帮我分析这个 Word 文件"、"读取这个 PDF"、"总结这个 Excel");(3) 上传文档文件并询问内容("这是什么"、"帮我看看");(4) 任何涉及 .docx、.xlsx、.pptx、.pdf、.md 文件格式转换的请求。

49 Updated 2 weeks ago
bruc3van
Data & Documents Solid

write-skill

去除文本中的 AI 生成痕迹。适用于编辑或审阅文本,使其听起来更自然、更像人类书写。 基于维基百科的"AI 写作特征"综合指南。检测并修复以下模式:夸大的象征意义、 宣传性语言、以 -ing 结尾的肤浅分析、模糊的归因、破折号过度使用、三段式法则、 AI 词汇、否定式排比、过多的连接性短语。

47 Updated yesterday
aresbit