52

When I typed multiline in coffeescript interactive mode, an error occrured.

For example, I want to try the following code:

kids =
  brother:
    name: "Max"
    age:  11
  sister:
    name: "Ida"
    age:  9

This Error was displayed:

coffee> kids = 
Error: In repl, Parse error on line 1: Unexpected 'TERMINATOR'
  at Object.parseError (/usr/lib/coffeescript/parser.js:463:11)
  at Object.parse (/usr/lib/coffeescript/parser.js:533:22)
  at /usr/lib/coffeescript/coffee-script.js:26:22
  at Object.eval (/usr/lib/coffeescript/coffee-script.js:64:17)
  at Interface.<anonymous> (/usr/lib/coffeescript/repl.js:18:26)
  at Interface.emit (events:27:15)
  at Interface._ttyWrite (readline:309:12)
  at Interface.write (readline:147:30)
  at Stream.<anonymous> (/usr/lib/coffeescript/repl.js:35:17)
  at Stream.emit (events:27:15)

I tried to use '\' as a newline,but the same error was displayed.

coffee> kids = \
Error: In repl, Parse error on line 1: Unexpected '\'
  at Object.parseError (/usr/lib/coffeescript/parser.js:463:11)
  at Object.parse (/usr/lib/coffeescript/parser.js:533:22)
  at /usr/lib/coffeescript/coffee-script.js:26:22
  at Object.eval (/usr/lib/coffeescript/coffee-script.js:64:17)
  at Interface.<anonymous> (/usr/lib/coffeescript/repl.js:18:26)
  at Interface.emit (events:27:15)
  at Interface._ttyWrite (readline:309:12)
  at Interface.write (readline:147:30)
  at Stream.<anonymous> (/usr/lib/coffeescript/repl.js:35:17)
  at Stream.emit (events:27:15)

I can't use multiline, so I can't use indentation.

What should I do?

My environment is the following:

  • OS: Ubuntu 10.04 lucid

  • coffeescript version 1.0.0 I installed coffeescript with PPA and apt-get command.

see this url: https://launchpad.net/~gezakovacs/+archive/coffeescript

Constantin Groß
  • 10,719
  • 4
  • 24
  • 50
utwang
  • 1,474
  • 11
  • 16
  • I highly recommend installing Node.js separately and then using `npm install -g coffee-script@1.3.1`. That way, you can easily install any version of CoffeeScript that you want and update to new versions as soon as they're available. – Trevor Burnham May 08 '12 at 14:50
  • Thank you for your comment. I changed the installation using ppa into using npm. – utwang May 08 '12 at 15:36

2 Answers2

118

You can also switch to multiline mode with Ctrl+V.

vahid abdi
  • 9,636
  • 4
  • 29
  • 35
fulmicoton
  • 15,502
  • 9
  • 54
  • 74
  • Ah, Ctrl-V rocks. Thanks – cpursley Oct 30 '13 at 13:51
  • doesn't work...coffee> fill = (container, liquid = "coffee") -> "filling the #{container} with #{liquid}.." [Function] coffee> fill "cup" 'filling the cup with coffee..' ------> shit = (container, liquid = "coffee") -> ....... "filling the #{container} with #{liquid}.." ReferenceError: container is not defined – Michael Dausmann Mar 27 '14 at 09:56
  • I am using node with vscode on Windows and it's terminal eats my ctrl-v and fires the paste from clipboard event. So I changed the hardcoded 'v' at node_modules/coffee-script/lib/coffee-script/repl.js:91:73 to a 'b' – Nick Sotiros Mar 18 '19 at 09:35
1

backslash works fine with my coffee 1.2.1... try to upgrade :)

alex
  • 11,935
  • 3
  • 30
  • 42