Some of my files/tabs somehow got to be Unix line endings, when I want Windows line endings. I can go to view > line endings > windows, but that applies it only for the current file/tab opened. I don't want to have to do it for every file (which I did). But even if I do this, when I open other files, sometimes they are set in Unix. Is there a single setting that can apply it for all files, whether they are opened or unopened?
If I go to preferences > Settings - default > and go to the default_line_endings setting, its value is set to 'system'. I know i COULD override this in my 'Settings - User' setting, but I didn't have to do this before the line endings somehow got all messed up. Is there another way?
Also, If i reinstall sublimetext, would this fix it, or are the line endings somehow dependent on the files themselves? I imagine it would be sublime text that decides which line endings to use, perhaps based on what line endings are in the file. But I don't know this for sure. Plus, all my line endings used to be the windows's CRLF, not Unix's LF.
Controlling the line endings in sublime text is currently kind of a pain, since it has no en masse way to view or set, current files, nor an en masse way to set it for future files.
Any knowledge would be appreciated.
use a text editor like notepad++ that can help you with understanding the line ends. It will show you the line end formats used as either Unix(LF) or Macintosh(CR) or Windows(CR LF) on the task bar of the tool. you can also go to View->Show Symbol->Show End Of Line to display the line ends as LF/ CR LF/CR.
To write your file in this way, while you have the file open, go to the Edit menu, select the "EOL Conversion" submenu, and from the options that come up select "UNIX/OSX Format". The next time you save the file, its line endings will, all going well, be saved with UNIX-style line endings.
On Windows, line-endings are terminated with a combination of a carriage return (ASCII 0x0d or \r) and a newline(\n), also referred to as CR/LF. On the Mac Classic (Mac systems using any system prior to Mac OS X), line-endings are terminated with a single carriage return (\r or CR). (Mac OS X uses the UNIX convention.)
Text files created on DOS/Windows machines have different line endings than files created on Unix/Linux. DOS uses carriage return and line feed ("\r\n") as a line ending, which Unix uses just line feed ("\n").
The LineEndings plugin / package is small, but works like a charm Visit it's GitHub repository to get a few details, because on its Package Control page there is no description.
It not only works, but also gives you an additional functionality -- you can change not only line endings, but also indentation method of all open files in one step.
After installation:
Open all files, in which you want to convert / change line endings and/or indentation method.
Press Ctrl+Shift+P, to bring Command Pallete and start typing lin
to locate Line Ending to all views: Windows
(for example).
Select it, hit Enter, and... you're done!
Repeat step 2, but type spaces
to locate Indentation: Convert to all views to Spaces
or tabs
to locate Indentation: Convert to all views to Tabs
to change indentation method of all open files.
Note, that either this plugin has a bug or Sublime Text 3 gets sometimes a bit wako. Some searches did not reveal above mentioned commands. And I had to close and reopen Command Palette and type sequence again. Especially, if you have any kind of linter installed in ST3, its command may interfere with LineEndings's commands, as you type lin
.
There is a plugin that will do what you want sublime-line-endings-unify
.
The default_line_endings
setting will only affect new files. Sublime will use whatever line ending is already there for existing files. Perhaps you have a tool (such as your source control system) that is changing the endings. Sublime itself will not change them unless you explicitly change it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With