How can I remove the ^M from my file in sublime text 3?
When I do a git diff in my branch I see that line endings have the characters ^M:
I want to replace these with Unix line endings before committing my changes.
I am using Ubuntu 14.04, git and sublime text 3.
I am looking for a way to change line endings in sublime text 3 not using other utilities or commands.
Solution 1:
This can be done without a plugin via the menu at the top or though the statusbar (but you need to enable the feature).
To change it through the menu at the top click View -> Line Endings -> Select desired line ending type.
To enable this through the status bar:
Click Preferences -> Settings
Then add "show_line_endings": true,
somewhere between the {}
brackets on the right-hand side.
Finally, save your changes.
This enables a small section on the right of the status bar that shows up at the bottom. It tells you the current EOL encoding and by clicking the box and selecting a different type it changes the files EOL character for you.
Another helpful option is file encoding which can be enabled in the statusbar as well by following the same setups above but also adding "show_encoding": true,
between the {}
marks.
Solution 2:
You can use dos2unix
command in linux (package dos2unix) or change line endings in Sublime Text under menu item View / Line Endings.