[BUG] Edit tool strips trailing spaces in Markdown files

Resolved 💬 8 comments Opened Nov 28, 2025 by HeoChangwon Closed Apr 18, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

## Summary

The Edit tool removes trailing spaces from old_string and new_string parameters, which causes issues when
creating Markdown files that require line breaks.

## Problem

In Markdown, to create a line break without starting a new paragraph, you need to add two trailing spaces at the
end of a line:

```markdown
Last Updated: 2025-11-28
Version: v16
Author: John Doe

However, when using the Edit tool, these trailing spaces are stripped during parameter transmission:

"Line 1 \nLine 2 " → "Line 1\nLine 2" (spaces removed)

This results in Markdown that renders as a single continuous line instead of multiple lines.

Current Workaround

Users must use the Bash tool with sed command to add trailing spaces:

sed -i '3,6s/$/ /' file.md

What Should Happen?

Suggested Improvements

  1. Preserve trailing spaces: Modify the Edit tool to preserve trailing whitespace
  2. Markdown-aware mode: Add an option that automatically handles line break syntax
  3. Documentation: Document this limitation clearly

Impact

This affects anyone using Claude Code to create or edit Markdown documentation, which is a very common use case.

Error Messages/Logs

Steps to Reproduce

If you make the following with markdown, there are no tracing spaces

Last Updated: 2025-11-28
Version: v16
Author: John Doe

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.0.55

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

Windows Terminal

Additional Information

_No response_

View original on GitHub ↗

This issue has 8 comments on GitHub. Read the full discussion on GitHub ↗