move_string_in_file
Move a continuous range of lines within a file or between files by specifying cut and paste boundaries using substring matching and an optional marker.
Instructions
Moves a continuous range of lines from one location to another within a file (or between files).
Specify cut boundaries and paste location using substring matching with an optional ⬥ marker.
Example 1: Move a definition before another definition: cutStartAt: "class MyClass:" (start at this line) cutEndAt: "class NextClass:" (end BEFORE this line) pasteAt: "\n⬥def target_function():" (paste adjacent to the \n)
Example 2: Move a paragraph after another paragraph: cutStartAt: "# Close the database" (start at this line) cutEndAt: "db.close()\n⬥" (end after the final paragraph line) pasteAt: "db.open()\n⬥" (paste after a different paragraph's last line)
⬥ in cut boundaries anywhere in a line marks the line to cut when the cut context contains multiple lines. No ⬥ is needed if cut context is within a single line only.
⬥ in a paste boundary must be adjacent to a \n or the start/end of the file. All lines will be pasted before/after the nearby \n or file boundary.
Whitespace at the end of lines is ignored when matching substrings.
After editing reports on blank lines around the cut and paste boundaries, simplifying clean up of nearby line spacing with small subsequent edits.
Does not alter indentation. Use indent_dedent to adjust indentation after moving if needed.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cutFilePath | Yes | ||
| cutStartAt | Yes | ||
| cutEndAt | Yes | ||
| pasteAt | Yes | ||
| pasteFilePath | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |