I'm trying to "beautify" sql code in codeMirror .
Autoformatting in not supported in codeMirror since v2 (current version is v4)
I've tried to use the old module formatting.js with autoFormatRange function ( the previous question on StackOverflow here). It doesn't seem to work properly with SQL. It makes indentation without any linebreaks
Did anyone figure out how to get this feature working on codeMirror v4 with SQL?
1. In a SQL document, right-click the SQL script, click Active Format Profile, and select the required format. 2. To apply the selected format profile, select the SQL document or the fragment of the code and press Ctrl+K, then Ctrl+F.
The SQL Formatter is used with the purpose to beautify the SQL statements. It formats the code automatically and its working is based on simple algorithms. It formats the code based on easy rules and helps to write fancy SQL code.
I've solved the problem using this js auto-formatter : https://github.com/zeroturnaround/sql-formatter
It does an excellent job at formatting SQL (demo here)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With