On 19/10/08 00:44, bgold12 wrote:
> How can I change the format of a text file that I'm editing in vim?
>
> I recently saved the source code of a web page and opened it in vim,
> and it said at the bottom [unix], which I assume means vim decided for
> some reason that this is a "Unix" file (or should be viewed as a Unix
> file), however every line ends with the CR symbol, ^M, so this is
> obviously a "Windows" file.
>
> I know I can do a simple substitution of all ^M's with nothing to get
> rid of them (assuming there are no other ^M's in the file that I
> wouldn't want to get rid of), but I'd also like to know if I can
> change that setting (the vim file format display) myself. Also, why
> wasn't vim able to recognize that the file was separated by CR/NL
> instead of just NL?

        :set ffs=
        :e ++ff=dos filename
        :w
        :enew
        :set ffs=dos,unix

Reading the file with "dos" fileformat (set forcibly as above, not 
"detected" via the 'fileformats' heuristics) will accept either CR+LF or 
LF only as an end-of-line (there must be at least one, probably the 
last, where the CR is missing). Writing it (in "dos" fileformat) will 
write CR+LF at the end of every line including the last.

I suspect your file lacked a proper end-of-line on its last line; the 
above will "repair" it.


Best regards,
Tony.
-- 
                        Get GUMMed
                        --- ------
The Gurus of Unix Meeting of Minds (GUMM) takes place Wednesday, April
1, 2076 (check THAT in your perpetual calendar program), 14 feet above
the ground directly in front of the Milpitas Gumps.  Members will grep
each other by the hand (after intro), yacc a lot, smoke filtered
chroots in pipes, chown with forks, use the wc (unless uuclean), fseek
nice zombie processes, strip, and sleep, but not, we hope, od.  Three
days will be devoted to discussion of the ramifications of whodo.  Two
seconds have been allotted for a complete rundown of all the user-
friendly features of Unix.  Seminars include "Everything You Know is
Wrong", led by Tom Kempson, "Batman or Cat:man?" led by Richie Dennis
"cc C?  Si!  Si!" led by Kerwin Bernighan, and "Document Unix, Are You
Kidding?" led by Jan Yeats.  No Reader Service No. is necessary because
all GUGUs (Gurus of Unix Group of Users) already know everything we
could tell them.
                -- Dr. Dobb's Journal, June '84

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to