Files
ruflo/.roo/rules-code/search_replace.md
T
rUv 4134144018 Add comprehensive guidelines for file operations, code editing, and search/replace functionality
- Introduced detailed guidelines for `apply_diff`, `read_file`, `write_to_file`, `insert_content`, and `search_and_replace` operations to prevent common errors and ensure best practices.
- Created a new index for tool usage guidelines to facilitate easy navigation and reference.
- Established rules for preventing apply_diff errors, emphasizing the importance of avoiding literal diff markers in code examples.
- Updated `.roomodes` with new roles and instructions for various development tasks, including architecture design, coding, testing, debugging, security review, documentation, integration, and deployment monitoring.
2025-06-11 16:09:59 +00:00

34 lines
1.0 KiB
Markdown

# Search and Replace Guidelines
## search_and_replace
```xml
<search_and_replace>
<path>File path here</path>
<operations>
[{"search":"old_text","replace":"new_text","use_regex":true}]
</operations>
</search_and_replace>
```
### Required Parameters:
- `path`: The file path to modify
- `operations`: JSON array of search and replace operations
### Each Operation Must Include:
- `search`: The text to search for (REQUIRED)
- `replace`: The text to replace with (REQUIRED)
- `use_regex`: Boolean indicating whether to use regex (optional, defaults to false)
### Common Errors to Avoid:
- Missing `search` parameter
- Missing `replace` parameter
- Invalid JSON format in operations array
- Attempting to modify non-existent files
- Malformed regex patterns when use_regex is true
### Best Practices:
- Always include both search and replace parameters
- Verify the file exists before attempting to modify it
- Use apply_diff for complex changes instead
- Test regex patterns separately before using them
- Escape special characters in regex patterns