Formatting SQL in VS Code

Arun KANNAN 0 Reputation points
2025-12-02T20:01:54.9133333+00:00

I need to be able to format sql in vs code and I just want to indent them, capitalize the right functions of sql.

Developer technologies | Visual Studio | Debugging
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Susmitha T (INFOSYS LIMITED) 1,630 Reputation points Microsoft External Staff
    2025-12-03T05:38:25.36+00:00

    Thanks for reaching out!

     
    It sounds like you’re looking to format your SQL code in Visual Studio Code to enhance readability by indenting and capitalizing the SQL functions. Here’s what you can do:

    Use Extensions for SQL Formatting: Consider installing extensions specifically designed for SQL formatting. Some popular ones include:
    SQL Formatter: This extension can automatically format your SQL queries to make them easier to read and maintain.
    Prettier - Code formatter: While it mainly targets JavaScript and HTML, it can format SQL with appropriate settings.

    SQL Formatter (by adpyke):
    1.Very popular, simple, fast
    2.Supports auto-indent, keywords UPPERCASE, proper line breaks.
    Install:

    1.Open VS Code
    2.Go to extension

    3.Search: SQL Formatter

    4."SQL Formatter (adpyke)

    Format shortcut:

    shift+ alt+ F (Windows)

    Shift+ Option + F (Mac) 

    **

    1. Manual Formatting**: If you prefer a hands-on approach, you can manually format your SQL by:
    • Indenting different levels of queries for clarity.
    • Capitalizing SQL keywords (like SELECT, FROM, WHERE) for better visibility. You might want to use a find-and-replace feature or a snippet feature available in VS Code for this.

    2.Keyboard Shortcuts: Familiarize yourself with keyboard shortcuts for formatting in VS Code. You can format the entire document using Shift + Alt + F.

    3. Settings for Formatting: Check your VS Code settings. Under Settings > Text Editor > Formatting, you can modify how you want your documents to be indented and how to wrap text.

    If you’d like to explore specific extensions or features further, here are links to additional resources:

    Let me know if you need any further help with this. I will be happy to assist.
    If you find this helpful, Kindly mark the provided solution as "Accept Answer", so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.

    1 person found this answer helpful.

  2. Q&A Assist
    2025-12-02T20:02:05.41+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    To format SQL in Visual Studio Code, you can utilize the built-in features for code formatting, which include indenting and capitalizing SQL functions. Here are the steps you can follow:

    1. Indenting: You can choose different styles of text indenting. To set this up, go to the Tools menu, select Options, then navigate to Text Editor. Under All Languages, you can set your preferred indenting style (None, Block, or Smart) and specify whether to use tabs or spaces for indentation.
    2. Capitalizing SQL Functions: You can manage the casing of SQL keywords and function names through the formatter options. This allows you to control how SQL keywords are displayed (uppercase, lowercase, or unchanged).
    3. Autoformatting: You can enable autoformatting as you type, which will help maintain consistent formatting throughout your SQL scripts.

    By configuring these settings, you can ensure that your SQL code is well-formatted and adheres to your preferred style guidelines.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.