This extension provides SQL formatting capabilities in VS Code using SQLFluff, an open-source SQL linter and formatter.
Features
- Format SQL files with SQLFluff
- Format selected SQL code snippets
- Support for automatic formatting on save
- Integration with VS Code's built-in formatting commands
Requirements
This extension requires SQLFluff to be installed on your system:
pip install sqlfluff
If SQLFluff is not installed, the extension will prompt you to install it when you attempt to format SQL code.
Usage
- Open a SQL file or select SQL code
- Use one of the following methods to format:
- Press
Shift+Alt+F (or Shift+Option+F on macOS)
- Right-click and select "Format Document" or "Format Selection"
- Open the Command Palette (
Ctrl+Shift+P or Cmd+Shift+P on macOS) and run "Format Document" or "Format Selection"
- Use the custom command "Format SQL with SQLFluff" from the Command Palette
To enable formatting on save:
- Go to Settings (
Ctrl+, or Cmd+, on macOS)
- Search for "Format On Save"
- Check the box to enable it for all languages or just for SQL
Extension Settings
This extension contributes the following settings:
sql-formatter.dialect : SQL dialect to use for formatting (default: "ansi")
Known Issues
- The extension currently uses a temporary file for formatting, which may cause issues with very large SQL files.
- Some SQL dialects may not be fully supported by SQLFluff.
Release Notes
0.0.1
- Initial release with basic SQL formatting functionality using SQLFluff
About SQLFluff
SQLFluff is an open-source SQL linter and formatter. For more information, visit the SQLFluff documentation.
| |