Brackets: How do you to force \n new lines instead of \r\n on Windows?

Created on 7 Dec 2014  路  16Comments  路  Source: adobe/brackets

As the title said. I looked at the brackets API and all it mentions is that things are normalized to use "the current line endings". I don't ever want brackets to think that \r\n is the current line ending, and _always_ use \n. How do I accomplish that?

F Editor Starter bug fix in progress

Most helpful comment

What is the status on this?

All 16 comments

@Deathspike There's not yet an API for that, but you can manually edit the getPlatformLineEndings() function.

We should add an API call for this. Marking this as a Starter Bug.

An additional note: Brackets on a Windows-machine does not correctly detect Unix-style line feeds and will always change to \r\n upon saving a document.

@Deathspike It absolutely should detect it -- please file a new bug with details if you're not seeing that. If you can share specific files that show the problem, please post them in the bug.

There was some discussion of this on IRC earlier today. Just so it's captured, my suggestions were:

  • Ideally we'd have a UI for switching the line endings of any of any open file (many other editors have this). Probably makes sense to put a toggle in the status bar, as long as that doesn't add too visual clutter.
  • But it also seems fair to add a defaultLineEndings pref, which basically changes the value of FileUtils.getPlatformLineEndings() -- so it would affect both new Untitled documents as well as any existing documents where the existing line endings can't be detected (e.g. opening a 1-line file). We need to be wary about the risk of an added FileUtils->PreferencesManager dependency creating a new circular dependency chain, however.

+1

+1

I wrote a plugin last night to help switch the newline character for an individual file.
https://github.com/LonelyStorm/brackets-newline

It will help until offical support is added.

@JBodkin: Much appreciated!

+1

@JBodkin works nicely for now. Many thanks!

@JBodkin thx for the plugin
really need this as a setting to change the default behaviour. even a hack would help

+1

+1 for a configuration option to force newlines as LF (or CRLF) as opposed to the platform default.

+1 Definitely looking forward to this - have run into quite a few issues with Docker that were all caused by line endings from Linux -> Windows.

What is the status on this?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AgamlaRage picture AgamlaRage  路  4Comments

udaykapur picture udaykapur  路  4Comments

armandbancila picture armandbancila  路  4Comments

Bluefirecracker picture Bluefirecracker  路  4Comments

rugk picture rugk  路  4Comments