Vim: Mac vs Linux ^ M Problem

I use Vim and GIT to develop my project on a Linux / Ubuntu machine. I used to use Windows, which means that the end of the line was in DOS format. Now, having switched to Linux, I always see ^ M confusing / annoying characters at the end of the line. Some people here:

How to convert ^ M linear jump to normal line break in a file opened in vim?

invited me to search / replace or use tools like dos2unix. These are good suggestions, but with a version-controlled project, this means that I have to add unnecessary commits for files after the change, and this is a big task, since it is not worth wasting time on it. So:

Is there a way to make Vim tolerant of this? That is, if the file ends with DOS, it saves it that way and uses its formatting for newlines, newlines, etc.

+3
source share
3 answers

The best answer I found is @Keith's answer in the comments:

"With subversion, you can set the svn: eol-style = native property, which will automatically convert the line endings to .. native type for all platforms. I don’t know if git has this function, but you can look into it first queue. Perhaps it is. "

And these links can be useful, as install:
http://help.github.com/dealing-with-lineendings/
http://git-scm.com/docs/gitattributes

+1
source

.vimrc .

set fileformats=unix,mac,dos                

, vimrc, , ( ) vim. vim .vimrc ( ) . , /etc/vimrc.

+2

Yes, you can install the following in vim: dos format file:

:set ff=dos

And also:

:set ff=unix
+1
source

Source: https://habr.com/ru/post/1784239/


All Articles