Ashley
Ashley

Reputation: 441

How to start a new line in Chrome console window?

I know this is a stupid question, but I really need help on it. How can I start new line on Chrome console? Every time I hit enter, the console runs my code. How can I start a new line without running the code? Thanks

Upvotes: 35

Views: 35164

Answers (5)

Ernest Trekpah
Ernest Trekpah

Reputation: 1

The below key combinations will do the trick: Shift + Enter ,if you are a Windows user. If you are a Mac user, you can use Ctrl + Return or Shift + Return.

Upvotes: -1

Sean Blanchard
Sean Blanchard

Reputation: 31

Just wanted to add an after thought... The shift + Enter is how you go to a new line without running the code, but I have noticed when I am writing a function and hit shift + enter after my first curly brace, it was giving me an error. So, I find that if you want to go to a new line after your first curly brace, hit enter, it will bring you to the next line with out running it, and from there, use the shift + enter if you want to start a new line. Then enter to run it.

Upvotes: 3

chekwenski
chekwenski

Reputation: 51

You can hit Shift + Enter if you are using Windows. If you are on a Mac you can use Ctrl + Return.

For more keyboard shortcuts

Upvotes: 5

mtrussell
mtrussell

Reputation: 299

Another option is to click on 'Sources', click the double arrow button next to 'Page', and click on 'Snippets'. There you can press the '+ New Snippet' button and write your code there.

When you are done writing your code, press Ctrl + Enter and it will run your code and open the console below your code snippet.

This is better for writing multiple lines of code because you can go back and edit your snippet and re-run more easily than re-typing the whole thing in the console.

And if you are using Firefox, they have a similar feature called 'Scratchpad'.

Upvotes: 12

Achraf
Achraf

Reputation: 1520

After typing out the first line, instead of hitting enter, hit shift + enter. This will bring you the next line without executing the code. So when you are done, hit enter, it will execute all the code you just wrote.

Also a well known tip, you can bring up JS console in any tabs in the chrome developer tool by hitting ESC (e.g. Elements, Sources etc.).

Upvotes: 54

Related Questions