[NBLUG/talk] vim fileformat

Barry Stump barry.stump at gmail.com
Mon Sep 11 14:14:19 PDT 2006


Ahh.  But that's the problem you see.  I'd rather not modify the files
because doing so requires checking them out via source control and
generates huge diffs (since every line of every file gets modified).
I just want to view them without the annoying ^M characters.

-Barry

On 9/11/06, Kyle Rankin <kyle at nblug.org> wrote:
> On Mon, Sep 11, 2006 at 01:42:27PM -0700, Barry Stump wrote:
> > I have some files whose format is mis-detected by vim.  They were
> > origionally dos format (lines ending with \r\n) but somewhere along
> > the way they had the occasion unix format (\n) line ending added.
> > Now, when opening them up in vim, I see all the annoying ^M characters
> > because it thinks (incorrectly) that they are unix format.
> >
> > I know that I can use
> > :set fileformat=dos
> > to change the file format, but because of source control, I can't just
> > save the file and reload it to see the changes.  How do I get vim to
> > change the format and re-process the buffer in place so that the
> > display of the ^M characters go away without changing the actual file?
> > Alternatively, a vim command line parameter to force it to read the
> > file as a certain format would also work, if such a thing exists.
> >
> > Anyone know any vim magic that can help?
> >
> > -Barry
> >
>
> One way to do this would just be to "repair" the file so that all those
> wayward \n lines were \r\n:
>
> perl -pi.bak -e 's/(?<!\r)\n/\r\n/g' filename
>
> --
> Kyle Rankin
> NBLUG President
> The North Bay Linux Users Group
> http://nblug.org
> IRC: greenfly at irc.freenode.net #nblug
> kyle at nblug.org
>
> _______________________________________________
> talk mailing list
> talk at nblug.org
> http://nblug.org/cgi-bin/mailman/listinfo/talk
>



More information about the talk mailing list