Workaround for 200 line limit - Success!
Over the last few days, Windsurf (with Gemini 2.5 Pro) has been struggling even more than usual when attempting to read files. I thought I'd ask it to explore solutions to this issue, and instead came across a solution that's even better - finally allowing Windsurf to reliably read and write files >200 lines.
After testing, I ended up with a simple approach where it reads chunks of a file until it reaches the end, then concatenates that into a single string. Surprisingly, when doing this with the 'view\_file' tool, I found it reliably reading 400 lines per chunk.
Below is the resulting instructions which I've put in my global\_rules.md. I'm guessing this will increase your token usage, so be warned. In my case, I just want things done correctly and faster, and this seems to be doing that well. Interested to hear if this works for you or perhaps you've come across a better method.
Insert this into **global\_rules.md**:
## Tool Use Methodology for Reliable Large File I/O 1. The Challenge: Tool Limitations with Large Files
Standard file access tools can be unreliable for large files.
view_file (when used without line ranges) often truncates content, showing only the beginning of the file. codebase_search and view_code_item also provide truncated results to conserve resources. Attempting to read or write large files in a single operation is prone to data loss and incomplete transfers.
2. The Solution: Chunked Reading
To overcome these limitations, we will always read files in controlled segments, or "chunks."
Tool: Use the view_file tool. Chunk Size: A chunk size of 400 lines has been tested and proven to be reliable and efficient. Process: Start by reading the first chunk: view_file(AbsolutePath="...", StartLine=1, EndLine=400). Concatenate the returned content into a single string variable. Continue fetching subsequent chunks by incrementing the line range (StartLine=401, EndLine=801, and so on). Stop when the view_file tool returns an empty response, which signals that you have reached the end of the file. 3. The Solution: Verified Writing
The write_to_file tool has been proven effective for writing large amounts of data at once, provided the data is correctly prepared.
Tool: Use the write_to_file tool. Process: First, use the Chunked Reading method described above to read and aggregate the entire file content into a single, complete string variable. Call write_to_file a single time with the complete string as the CodeContent. This is more reliable than writing in multiple, smaller appends. 4. When to Use This Methodology
This should be our standard operating procedure for all file manipulations, specifically:
When reading any file whose size is unknown or suspected to be large. When needing to create an exact duplicate of a file. When performing any "read-modify-write" operation where data integrity is critical. By adhering to this tested methodology, we can ensure all future file operations are accurate and dependable.