0

I'm using git and vim. My buddy is using git and TextMate. I ran into an issue today where I added a file using vim and git. He modified it in TextMate. I then pulled his change. I added a few lines, but the coffeescript compiler (and vim-coffee-script) threw a fit because they didn't recognize my newlines. So, I ran :set ff and it shows mac now, where it used to show unix.

Why is coffeescript not recognizing the newlines? And how can I prevent this from occurring in the future, either with my git or vim configs?

My vim config:

set ffs=unix,mac,dos

Neither of our git configs do anything with core.autocrlf.

Bradford
  • 4,143
  • 2
  • 34
  • 44
  • What error do you get with coffeescript? – Usagi Apr 10 '12 at 18:34
  • It really depends on the code, but when I view the JavaScript it creates, it is acting as if I have no newlines and does not match the JavaScript that the same code generates when I run it through the "Try Coffeescript" page on the CoffeeScript website. – Bradford Apr 10 '12 at 18:37
  • 3
    OS X uses unix line endings, unless you are frequently editting pre-OS X files, you don't need "mac", and you can set ff manually if you do have a need. – ergosys Apr 10 '12 at 18:38
  • I did not know that mac was needed for compatibility with older systems, @ergosys. Thanks. – Bradford Apr 10 '12 at 18:39
  • 2
    If you get into the situation where `ff=mac`, you can use `:verbose set ff?` to find out what script/plugin last set the value; that might help in tracking down what is causing the problem. – Chris Johnsen Apr 11 '12 at 06:12

1 Answers1

0

If your friend doesn't have TextMate set up to use unix line endings, he should do that. Then once both of you are using unix line endings, use dos2unix to convert your whole repo.

You should also make sure git will correctly handle crlf. See these two questions: - Definitive recommendation for git autocrlf settings - Git 1.6.4 beta on Windows (msysgit) - Unix or DOS line termination

You may also want to investigate modelines. While these aren't as useful for line endings, they're great for indentation. Vim supports them natively and TextMate has a plugin to add support for emacs-style. (And vim can support emacs-style too -- or you can just use both.)

Community
  • 1
  • 1
idbrii
  • 10,975
  • 5
  • 66
  • 107