10

I'm using Data Grip and writing queries for use with Presto. How can I get Data Grip to format my queries so they will be neat and easy to read?

enter image description here

enter image description here

GiladZa789
  • 111
  • 1
  • 7

2 Answers2

8

Ctrl+Alt+L formats your code.

Settings | Editor | Code Style | SQL to adjust.

moscas
  • 9,064
  • 36
  • 42
  • Hi @moscas I've tried that and it does absolutely nothing! It will say "No lines changed: content is already properly formatted" even when the code is not formatted! any ideas? – GiladZa789 Oct 05 '20 at 10:22
  • @GiladZa789 That means that your code is formatted according to defined code style. You need to set up code style to match you expectations – kassak Oct 09 '20 at 06:10
  • @kassak I've set up code style, and yet nothing happens. I can write a super-long line and then press Ctrl+Alt+L and it won't even wrap the text. Any ideas? – GiladZa789 Oct 15 '20 at 08:34
  • Hm, are you editing the SQL file or a console? What dialect do you use? A screencast will be useful here – moscas Oct 15 '20 at 11:49
  • Hi @moscas, I've added two screenshots, hope that's helpful. I'm writing in Presto which should be general SQL. Appreciate your help here. – GiladZa789 Oct 21 '20 at 12:23
  • 2
    Got it! The formatter doesn't wok for the dialects which are not supported. It will be fixed in 2020.3 – moscas Oct 27 '20 at 12:03
  • 1
    Mac: Cmd + Option + L – Lea Fox Sep 22 '21 at 00:21
5

For macOS:

Command + Option + L

Aleksei Mialkin
  • 2,257
  • 1
  • 28
  • 26