Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove carriage return from output in Sublime Text 3

I'm learning ipython for data analysis and I'd like to use Sublime text, my favorite text editor. However, I'm having a problem with "CR", carriage return, being output instead of the original "stuff" I want to display. This makes copying/pasting to another location a hassle because I'll have to manually delete those characters. It's also frustrating to look at.

Here's an example from the textbook I'm using: sublime output

Running the same command in terminal and it works fine Terminal output of same command

Although it displays properly in terminal, I really would like to use a REPL in sublime because of the helpful plugins such as autocomplete and code intelligence. I've tried changing the user settings default_line_ending but nothing helped. If someone knows how to get rid of those carriage returns or at least hide them from the output, I'd be very happy.

Thank you

like image 908
Maurice Abney Avatar asked Nov 06 '15 20:11

Maurice Abney


1 Answers

If your terminal supports it, you can try the following command to remove the existing CRs:

sed -i 's/\r//g' FileWithCarriageReturns.foo

sed is a stream editing command which when executed as above, will search through the specified 'FileWithCarriageReturns.sh' and remove all carriage returns (seen as \r ) from the file

Once you've done that, go into your Sublime Text settings and override the default line ending property to be 'unix' :

{ "default_line_ending" : "unix" }

like image 156
Chase Turner Avatar answered Nov 14 '22 03:11

Chase Turner