Sublime Forum

Display line endings, line by line, like in Scintilla

#1

Hi,

Is it possible to add the possibility to show line endings like in Scintilla?

After each line see special chars [LF] or [CR] or [CR][LF]

It’s usefull to see, line by line the line ending char(s)

Thanks,
Jerome

0 Likes

#2

+1 for this common feature in Windows editors… very handy at times.

0 Likes

#3

+1 from me also. I need to know clearly if there is a CR vs CR LF. I use text editors to view and manipulate data files quite often, and the distinction is significant. Scintilla displays them exactly like Notepad++ and that’s precisely what i need.

0 Likes

Show All Characters
#4

Could this be implemented in a plugin? I’m not familiar with the API, but would take the challenge on if it is possible.

0 Likes

#5

This would be awesome! Anyone know how to do this? I have a hard time believing this isn’t already in SL?

0 Likes

#6

If you don’t want these displaying permanently then you could just use Find and Find All using the regex ‘\n’ and/or ‘\r\n’. This allows you to scroll up and down but, of course, you could use Replace as well.

While this may be possible via a plug-in I suspect it will muck up all the scoping rules.


0 Likes

#7

As of now, I don’t think this can be done (even via plugin). From what I have seen, and a quick search of the issue pointing me here, Sublime Text normalizes line endings to “\n” when the file is loaded (I verified this as a file I created with “\r\n” did not contain any “\r” characters when I did a regex find). When the file is saved, all line endings are converted to what ever is specified (or opened with). I tested this by creating a file containing both line endings, opening it in Sublime Text, making some modification and saving it. So good news, when you save in Sublime, all the line endings should be consistent, bad news, you can’t actually see individual line endings.

0 Likes

#8

+1 to also show CR and LF. Or add a preference for draw_white_space_lineendings.

This is a duplicate of Forum Post - Show tabs, white spaces, line breaks
Also vote for this on Userecho - Is it possible to Show all characters (spaces, TABs, CR, LF, etc.)

0 Likes

#9

Technically ST3 can display carriage returns as is…if you manually read in a file and populate the view buffer…

This is in Sublime Text 3 when a file is manually read in and populated to the view buffer:

I realize opinions differ on whether it is really needed to show carriage returns and line feeds, but really I am just showing that Sublime Text can technically show carriage returns. Line feeds seems redundant since you can see the line on the next line number, but again, opinions differ on this.

1 Like

#10

The reason to want to see both CR and LF is if I may be reading some wierd file that was maybe created-edited with a mixture of buggy Unix and Windows editors so that the file might contain a mixture of CR-LF and CR or other line endings structures. It is sometimes nice to see what is exactly going on with the file.

0 Likes

#11

But isn’t this not really an issue since ST saves the entire buffer with the specified line ending anyways? You could mix the two, but upon save, all line endings will be the same (whatever is specified). Or maybe I am missing something?

0 Likes

#12

+1 here too. I have it on almost permanently in Notepad++ & am tired of switching back and forth just to verify the line endings for files sent to me that have been created on Linux.

0 Likes

#13

Did you read the previous post ? What do you want to verify ?
You can check the line endings in the menu View -> Line Endings.
And there’s no mixed line endings in a view, ST normalize them when loading the file.

If you want to mix line endings in a file, you must use another editor.

0 Likes

#14

Alright then. Leaving aside the fact that an option would reside in the view menu which has no visual effect when changed, I’ll put this one to bed. Automatic normalization of line endings will do.

0 Likes

#15

Take a look at https://github.com/SublimeText/LineEndings
Also available at Package Control.

0 Likes

#16

I registered here, just to give the use case I commonly run into for needing to see line endings. If you don’t already know why this is important, and why I have to keep Komodo Edit around on OS X, then you’ve probably not done a lot of cross-platform development involving patches before. I work with a Windows/OS X/Linux project, and there are patch files created by TortoiseSVN users, *nix command line SVN users, etc. Most of the files in the repo are forced to LF, but the project files for Windows are all CRLF endings, and occasionally a new file gets committed and doesn’t get a propset applied to force it to LF because Windows coders ain’t got time for that. So you then end up with large patches that have a mix of LF or CRLF in the diff-specific lines, as well as in the content. Command line diff tries to remove all trailing CRs if it thinks they’re only there because the diff came from Windows, but if some of those files were also Windows files, it just ruined their diff. My point is, as far as the diff utilities are concerned, these mixed ending files are completely valid, and a text editor capable of displaying them exactly as-is is not only helpful, but required for working with them at times. I’d like to stop having to fire up Komodo every time I need to edit one. If ST is going to trash that data just by opening and saving a patch file, then it’s useless to me for viewing/editing patch files and I’ll have to keep Komodo around. It’s still looking to replace Aptana as my PHP development environment though.

0 Likes

#17

This could be coded up in a plugin. You could run the command on a view, and the view would be manually reloaded showing all carriage returns. While in this raw line edit mode, you could look at the line endings and enter new ones: maybe enter gives you unix, and shift+enter gives you windows style. I have a plugin locally on my machine that can do this (the user interface needs a little work), but if you are interested, I may try to revive it and hammer out the issues to make it usable. It would currently be for ST3. Anyways, just thought I’d share.

0 Likes

#18

I know this may sound like a stupid question, but how do I “manually read in a file and populate the view buffer” with ST3? All I need to do is verify/be certain line ends are unix-style instead of Windows or visa-versa.

[quote=“facelessuser”]Technically ST3 can display carriage returns as is…if you manually read in a file and populate the view buffer…

This is in Sublime Text 3 when a file is manually read in and populated to the view buffer:
[attachment=0]Screen Shot 2013-03-10 at 10.38.44 AM.png[/attachment]

I realize opinions differ on whether it is really needed to show carriage returns and line feeds, but really I am just showing that Sublime Text can technically show carriage returns. Line feeds seems redundant since you can see the line on the next line number, but again, opinions differ on this.[/quote]

0 Likes

#19

[quote=“MKANET”]I know this may sound like a stupid question, but how do I “manually read in a file and populate the view buffer” with ST3? All I need to do is verify/be certain line ends are unix-style instead of Windows or visa-versa.
[/quote]

I had decided to code up a simple plugin to do this (it expects files to be UTF-8 though…I know, I should get off my butt and make it more more friendly to other encodings…but I am also lazy).

github.com/facelessuser/RawLineEdit

0 Likes