Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Somehow, some 40 files (mostly Python modules) in my project have \r\n (Windows style) as line endings. I'd like to change them to \n (Unix style) line endings, but Komodo Edit doesn't appear to provide a way change existing files' line endings, and a simple regexp find and replace using Komodo doesn't work either.

share|improve this question

3 Answers 3

up vote 2 down vote accepted

There is actually a built-in feature for this in Komodo, but it's hard to find.

Right-click the file tab select "Properties and Settings". Under Category: Properties: File Settings, change "Line Endings" to UNIX (\n) and de-select "Preserve existing line endings".

This is fine for individual files, but it would be a bit of a hassle if you were trying to do several files as a batch. For that, you could wrap some of swatso33's suggestions into a saved command using interpolation shortcuts.

share|improve this answer
    
Excellent, thanks. I ended up spendin 20 minutes last night changing them by doing open file -> copy contents -> command w -> close and delete file -> command shift t (which prompts to recreate the file) -> paste contents -> save. I got each one down to about 8 seconds by the end lol, but wasted time early on doing extra steps. –  orokusaki May 3 '12 at 21:49

You can do this with either perl or sed using:

 perl -pe 's/\r?\n|\r/\r\n/g' inputfile > outputfile  # Convert to DOS
 perl -pe 's/\r?\n|\r/\n/g'   inputfile > outputfile  # Convert to UNIX
 sed -e 's/$/\r/' inputfile > outputfile              # UNIX to DOS  (adding CRs on Linux based OS that use GNU extensions)
 sed -e 's/\r$//' inputfile > outputfile              # DOS  to UNIX (removing CRs on Linux based OS that use GNU extensions)perl -pe 's/\r?\n|\r/\r/g'   inputfile > outputfile  # Convert to old Mac

Code snippet is from http://en.wikipedia.org/wiki/Newline#Conversion_utilities

share|improve this answer
    
Thanks swatso33 –  orokusaki May 3 '12 at 2:09

At http://bugs.activestate.com/show_bug.cgi?id=93976 I give a macro that changes the line-end setting and the actual line-endings when a file that is under Git SCC is opened in Komodo.

You can also modify that macro to quickly update all loaded files.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.