In VS2005 I can save a file with LF instead of CR/LF. But is there a way to configure VS2005 so it always forces a file to be saved with LF even if the file had CR/LF for all lines when it was opened (i.e., without me needing to select the pulldown)?
One does not need Perl for it, every scripting langauge could be used for such kind of tasks. I just pointed out that there will be no option "build-into" MSVC to achieve that. One could e.g write a small com-add-in for that....
>> One does not need Perl for it Agreed... it's a bit overkill; installing a scripting language (I have nothing against Perl) just for this, especially when you can just download dos2unix and unix2dos... http://www.bastet.com/
I already have programs to remove the CR's. VS has an option to save as LF but it is on a per file basis. I was looking for a default option so that when I'm editing any other CR/LF files it will automatically save as LF. Since that option doesn't exist I'll just live with it.
>> Since that option doesn't exist I'll just live with it. There is no such option but you could set up an external tool to do it using one of the programs discussed here. For example, if you know all your source is in the same folder you could set up a tool to process all *.c *.cpp *.h files in that folder. There are variables you can use to facilitate this, such as $(targetdir). Ok, so you'd still have to select a menu option but you'd only need do it once after your editing session. You could even set it up as a hot-key combination to make it really easy. I have a similar mechanism set up to open vim and display the current file at the line it's currently at in VS because I prefer the editing facilities in vim. I use CTRL-` to fire this up. I'm sure you can figure out a way to do what I've suggested here.
It is not a big deal. It only needs to be done once and when I edit it will keep the LF's. The reason for looking for the default was because when I pickup some new files I don't have to know if they are CR/LF or LF files.
In some cases they are. The target system's Makefile can't have CR's and vi shows ^M which annoys some people.
You may wonder why I'm not strictly on the target system. The reason is because my code is totally system independent. It lives on Windows where I do most of my editing and testing. I have a button that copies the changed files over to the target system where I build and test. So the Makefile for that system must not have CRs and sometimes I like to edit (or checkin) on the target system. Since VS doesn't care if the file ends with LF only then it is best to keep it that way. Now, every now and then I need to bring in another file that someone created on Windows but didn't know about this LF thing. Granted there are lots of different ways to handle this, one of which is to d2u the file at the time it is being copied but I wanted to ask the question just incase VS had that option.
>> In some cases they are. The target system's Makefile can't have CR's and vi shows ^M which annoys some people. Yes, it annoys me too :) You know that most xfer clients can be configured to automatically remove these though, right?
>> You may wonder why I'm not strictly on the target system. Not at all, I target about 10 different platforms, but I write the code mainly on Windows because I like the VS IDE.
>> So the Makefile for that system must not have CRs and sometimes I like to edit (or checkin) on the target system Have you ever looked at SCons? It's a platform independent make system. It's very simple to convert Makefiles to SCons scripts. The SCons framework is, itself, python based so it's very rich. You might want to try looking at it as the time to convert Makefiles shouldn't be too long but then you'll have a build mechanism that will work on all platforms, greatly reducing your makefile maintenance overhead. It also have no care about line endings :) http://www.scons.org/
>> I transfer with xcopy /m. Samba share? I think, but I might be wrong, but I think that Samba can be configured to do this translation automatically... but you'd have to check the man pages for smb.conf or as in the appropriate TA. If not you could always switch to using something like winscp, which will do it for you.
>> My company has a make system and would not want me to change it but I'll bring it up since it has some advantages. Understood... we too have a build system but I managed to get it working with SCons with minimal effort (in fact simpler than the way it would normally interface because of the x-platform nature of it).