69

Firebug has a multiline feature in their console tool. Is there a way to get this functionality with the debugger tool in Safari/Chrome?

minimalpop
  • 6,997
  • 13
  • 68
  • 80

9 Answers9

140

Shift-Enter on Windows allows multi-line entry where Option-Enter works on Mac.

A more fully featured editor is in the works.

MrBester
  • 1,516
  • 2
  • 10
  • 2
  • 8
    Ctrl-Enter and Shift-Enter also work (for me!) on Mac OS (I'm using Chrome 14; can't vouch for earlier versions.) Also, pasting in multi-line code 'just works'. To run multi-line code, press Enter. – Sam Dutton Sep 14 '11 at 14:46
29

For Google Chrome, you can Sources >> Snippets >> + New Snippet in the Developer Console.

enter image description here

Once you have written your multi-line code, you can execute it with the enter image description here button or with Ctrl + Enter as mentioned on the button.

This is like a text-editor which has a host of keyboard shortcuts which you can find under Settings >> Shortcuts under Text Editor

enter image description here

Good Luck.

Aakash
  • 21,375
  • 7
  • 100
  • 81
17

I recommend this:

  1. Write debugger; and hit Enter, in the console tab
  2. This takes you to the Sources tab; if not, make sure debugger breakpoints are active
  3. Now you can write whatever you want in the Sources tab, which acts like a full IDE with features like newline and indentation
  4. Select any part of your code to run, and right-click, choose Evaluate in console
Saeed Neamati
  • 35,341
  • 41
  • 136
  • 188
12

http://code.google.com/p/chromium/issues/detail?id=35487

Not yet.

UPDATE: the status of the issue I linked to is now "fixed".

Tomas Andrle
  • 13,132
  • 15
  • 75
  • 92
  • 10
    For those who might only read this answer: multi-line console entry is now possible in the Chrome dev tools, as per MrBester's answer below. – Sam Dutton Sep 14 '11 at 14:43
  • 1
    imho - the snippets feature is the best way to handle this: https://developers.google.com/chrome-developer-tools/docs/authoring-development-workflow#snippets - plus you get the added benefit of creating lots of them and reusing them. – PhillipKregg Feb 14 '14 at 17:24
11

Try pressing option (shift on Windows) at the same time as return. Inserts a newline on Mac.

dariom
  • 4,413
  • 28
  • 42
Scott Hyndman
  • 923
  • 1
  • 7
  • 15
5

Shift + Enter seems to work in chrome browser. I am using ubuntu 12.04 as my operating system. Thanks to Mr Bester and Sam Dutton for their inputs.

Bimal
  • 865
  • 10
  • 18
2

It is simple ... place semicolons between your multilines and it will work in the console.

For example

if you have html like this

<div id="test">This is a test statement</div>

You could paste following in the console and it will work

var ourTest = document.getElementById('test'); alert(ourTest.innerHTML);

I hope it helped.

S. A. Malik
  • 3,465
  • 6
  • 37
  • 56
0

There is cool extension to chrome https://chrome.google.com/webstore/detail/bigconsole/klommbdmeefgobphaflhmnieheipjajm

It just add another tab named BigConsole and it allow multiline code execution

Piotr Galas
  • 4,518
  • 2
  • 21
  • 30
-4

Try using the notepad (or someting else) and then copy/paste to the console, works for me!!!!