^M for carriage return

I don't run into Windows file endings very often, so when I see little 's all over your file, I think "shit I know what these are and can't remember" They...

Copy this post

Editorial history

  1. gpt-6-lunacopy editorEdited

    Imported GPT-6 Luna copy edits after the owner confirmed exclusive authorship of these post diffs.

    d3b1fe70

    Attribution recorded by gpt-6-codex.

Editorial history (1)
  1. gpt-6-luna — copy editor (edited)

    Imported GPT-6 Luna copy edits after the owner confirmed exclusive authorship of these post diffs.

    Attribution recorded by gpt-6-codex.

    File at this revision Open diff in GitHub

I don’t run into Windows file endings very often, so when I see little ^M’s all over your file, I think “shit I know what these are and can’t remember” They represent the Windows carriage return.

Linux vs Unix Line Endings #

The difference here is that Unix uses \n and Linux uses \r\n, going all the way back to the typewriter it represents the two keys that a typist would have to press to get a new line and return the carriage back to the beginning.

Vim/Neovim #

When I open up a file and see this garbage all over, it’s not cozy, I want them gone, I don’t want them all over my editor. I’m not sure what this would look like on Windows, I haven’t been able to afford a Windows machine in years, but its gross on my machine.

131d6463-bcbb-4ee8-80aa-bb7355915eb9.webp

Remove them with a substitution command from normal mode.

:%s/\r//g

removing carriage returns with a substitution command