View Full Version : newlines at end of file
ravuya
2005.09.06, 06:12 PM
Is there a way to get Xcode to add newlines to the end of each source file that I edit? I'm sick and tired of taking my Xcode-created source over to my linux box and having Linux GCC moan about it.
Alternatively, does anyone have a quick sed script or something that'll jam newlines on there to shut GCC up?
AnotherJake
2005.09.06, 06:43 PM
Go to Preferences... under the Text Editing category choose For existing files: Unix (LF), instead of preserve.
Another way is to right click on the file in the IDE, in the outlineView on the left, and get info... Then choose Unix (LF) as the line endings.
OneSadCookie
2005.09.06, 08:14 PM
er, that's not what was asked...
I just add -Wnewline-eof to the cflags, so that GCC on the Mac complains too :)
AnotherJake
2005.09.06, 08:38 PM
er, that's not what was asked...
Whoops! Hasty reading :blush:
ravuya
2005.09.06, 09:41 PM
So there is no setting to make Xcode automatically add a newline at the end of the file?
I guess I'll have to do it by hand. Thanks
MattDiamond
2005.09.07, 08:05 AM
A quick Google tells me that BBEdit has an option to add an end-of-line character automatically if it's not already there when it saves the file. Not sure if their free editor has that option or not. Other editors might have such a feature also.
Using Automator and the latest BBEdit, you should be able to process all your files in one swoop. I don't have the TIger-enabled version unfortunately otherwise I'd try it...
If you have scriptability or a macro recorder, either in your editor or as an extension to your OS, you could easily set up a script to do add a <CR>.
These are all attempts at one-off solutions; OSC's suggestion seems very sensible for maintaining your files going forward...
ravuya
2005.09.07, 08:31 PM
Well, I was thinking of a cheap shell script like echo >> file.cpp, but automator is probably a good idea.
vBulletin® v3.6.8, Copyright ©2000-2008, Jelsoft Enterprises Ltd.