Skip to content

Defaults to CRLF line endings instead of LF on Unix systems #772

Closed as not planned

Description

I love using edit on Arch as a replacement to nano. However, the one issue I have with it is that when making new files, it will use Windows line endings (CRLF) instead of Unix line endings (LF). This has caused me to make config files and then get weird errors and have to figure out I had to run dos2unix on them to fix them.

The worst offender was when I installed doas and I had no idea why it wasn't working without having a single clue that /etc/doas.conf which I created with edit had CRLF line endings.

A fix would be to either have some sort of config to select which kind of line endings to use, or just default to LF line endings on Unix. Or both.

Activity

  1. DHowett commented on Mar 18, 2026

    @DHowett
    Member

    Hmm. It's supposed to default to LF line endings on all non-Windows platforms:

    newlines_are_crlf: cfg!(windows), // Windows users want CRLF

    Which matches the behavior I see when I launch it anew on Linux:

    Image

    On all platforms: If you're opening an existing file, it will follow the dominant newline format it finds in that file.

    // We'll assume CRLF if more than half of the lines end in CRLF. If there is only a single line, we'll use the platform default.
    let newlines_are_crlf = if lines == 0 { cfg!(windows) } else { crlf_count > lines / 2 };

  2. ItzELECTR0 commented on Mar 18, 2026

    @ItzELECTR0
    Author

    On all platforms: If you're opening an existing file, it will follow the dominant newline format it finds in that file.

    Yes if a file is already LF then edit won't overwrite that but for me when making new files they are saved with CRLF by default for some reason.

  3. ItzELECTR0 commented on Mar 18, 2026

    @ItzELECTR0
    Author

    I have a reproducible scenario. I'm using the msedit package on Arch Linux for context.

    I do msedit test.txt and write whatever text inside it. It indeed says [LF] at the bottom. I save and exit with CTRL+Q.
    I then do msedit test.txt again and now the bottom bar says [CRLF] instead of [LF]. I add some more text, save and quit again.
    Then running file test.txt will say "test.txt: ASCII text, with CRLF, LF line terminators"

    Edited because I didn't finish writing the first time lol

  4. ItzELECTR0 commented on Mar 18, 2026

    @ItzELECTR0
    Author

    Yes if a file is already LF then edit won't overwrite that but for me when making new files they are saved with CRLF by default for some reason.

    Ok I just realized I contradicted myself. Ok so it creates them as LF but overwrites as CRLF.
    But that's still an issue.

  5. DHowett commented on Mar 18, 2026

    @DHowett
    Member

    Uh, horrifyingly, it doesn't reproduce in main and it was (according to a bisect) fixed in #741. Leonard Hecker (@lhecker) wat

  6. ItzELECTR0 commented on Mar 18, 2026

    @ItzELECTR0
    Author

    Uh, horrifyingly, it doesn't reproduce in main and it was (according to a bisect) fixed in #741.

    Can confirm it's still going on with the msedit package from the extra repo on Arch, version being 1.2.1-2

  7. lhecker commented on Mar 19, 2026

    @lhecker
    Member

    Is there any particular content you're typing into? Or are you pasting into the editor something particular? I seem unable to reproduce this issue.

  8. DHowett commented on Mar 19, 2026

    @DHowett
    Member

    LOL, no, my bisect run sucked.

    We fixed this in #739.

  9. ItzELECTR0 commented on Mar 19, 2026

    @ItzELECTR0
    Author

    Is there any particular content you're typing into? Or are you pasting into the editor something particular? I seem unable to reproduce this issue.

    Nope, just about any file. I'm not pasting either, just typing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions