[TxMt] Feature Request: File/Scope Specific Line Endings

René Schwaiger sanssecours at f-m.fm
Tue Nov 1 10:08:48 UTC 2016


Hi,

I recently created a [TextMate bundle][] for [ABNF][]. The [RFC][] that describes the current version of ABNF explicitly states that the standard uses CRLF (Carriage Return + Line Feed) for line endings.

[TextMate bundle]: http://github.com/sanssecours/ABNF.tmbundle
[ABNF]: http://en.wikipedia.org/wiki/Augmented_Backus–Naur_Form
[RFC]: https://tools.ietf.org/html/rfc5234

TextMate already supports different line endings in the “Save Dialog”. This works quite well, as far as I can tell. We can also explicitly tell TextMate to always use specific line endings via “Preferences” → “Files” → “Line Endings”. If we set this option to “CRLF” then TextMate adds the entry

   lineEndings      = '\r\n'

to the global properties file `Global.tmProperties`. However, in both the current development version of TextMate (2.0-beta.12.26), and the lastest normal release (TextMate 2.0-beta.12.4), this feature does not seem to work as expected:

---

# Steps to Reproduce

1. Set line Endings to “CRLF” in “Preferences…”
2. Create a new file via `mate test.txt`
3. Enter the following text in the new document

       line 1
       line 2

4. Check the line endings via the command `file test.txt`

# Expected Result

The `file` utility displays the following output:

   test.txt: ASCII text, with CRLF line terminators

# Actual Result

The `file` utility displays the following output:

   test.txt: ASCII text

---

Maybe I am doing something wrong here? 

I would also expect that the default “Save Dialog” reflects the line ending option currently set via “Preferences…”. This seems not to be the case. If I save a new document via `⇧` + `⌘` + `S`, TextMate always shows “LF” as default option for line endings. Again, maybe this might be a problem with my expectations on how the system works.

After this long  introduction :o) here is my feature request. It would be very nice if it would be possible to set scope- and file-specific line endings. For example, I want to create a new “Settings” item set to the scope `source.abnf` that contains the following code:

   { lineEndings = '\r\n'; }

The “TextMate Settings” grammar currently marks `lineEndings` as invalid key. I suspect this feature is currently not available/implemented? If this is correct, then please consider this a (low priority) request to add this feature.

Kind regards,
 René


More information about the textmate mailing list