by MatthewPhillips · 15y ago · 0 comments
Later I opened the file on Windows (Notepad++) and saw that one line had not been indented, which wasn't showing up on Vim/Gedit. I never tested it to see if that was indeed the problem, I'd already moved on.
if one
if two
two
oops
one
The error given is: Parse error on line 4: Unexpected 'INDENT'Since the compiled JS is just-the-code-I-wrote-myself only in a slightly more verbose curly syntax, troubleshooting my own CS code even when compiled in JS is totally not an issue. Thankfully Coffee does not minify or otherwise obscure the code.
Alas, poor error messages are a big -
# vim: ts=2 sw=2 et : set listchars=tab:»·,trail:·
set list
That will show tabs with a little double arrow and trailing dots, and show whitespace past the end of the line with dots.Regardless, with coffee being default in Rails 3.1, I'm sure editor support will show up quickly. For the time being though, I just stumbled onto this: https://github.com/kchmck/vim-coffee-script (have not tried it myself).
The tabstop variable sets the ratio of tabs to spaces (in this case, one tab is equivalent to two spaces).
The shiftwidth variable controls how much a line gets moved when it gets "shifted". In VIM pressing << in Normal mode on a line does a left shift. With a shiftwidth of two, it will move it over two spaces to the left. >> is right shift. There are many more ways of shifting, however.
The expandtab option sets it up so that every time you hit the tab key, VIM will insert the equivalent number of spaces according to the tabstop. In this case, pressing tab will give you two spaces.
gg=G:retab!<CR>