October 28, 2002
Changing Line Endings in VIM
I was somewhat vexed by this problem this afternoon for an hour or so. As a mental note to myself I thought I would put the solution here, then I am not going to forget it easily.
:set fileformat=unix<cr>
:w<cr>
I was trying to create a path file for the Cygwin installation of Python on my laptop. Except I created the file in Windows, and so when site.py tried to read the file it fell over the line endings. Of course I didn't realise this until I went through site.py line by line.
I then figured out that the file had windows line endings and so the script was balking at my perfectly reasonable suggestions for what to put into the sys.path environment variable.
Still, a valuable lesson was learned. In future, to make sure a configuration file for Cygwin is in the right format just open it in VIM and type the commands above. All is now well with the world.
The reminder was at the bottom of tip 26 on the VIM site. For the really curious, I was trying to automatically add a couple of directories to my sys.path every time I start up Python using the site customising hook.
Posted by Andy Todd at October 28, 2002 03:37 PM