Skip to content
| Marketplace
Sign in
Visual Studio Code>Formatters>BSPS MyBatis FormatterNew to Visual Studio Code? Get it now.
BSPS MyBatis Formatter

BSPS MyBatis Formatter

복세편살

|
12 installs
| (0) | Free
A VS Code formatter for MyBatis XML files.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

BSPS BSPS MyBatis Formatter

A VS Code extension that automatically formats MyBatis XML mapper files. It formats SQL inside MyBatis tags using proper indentation and configurable style options.

Features

  • Formats SQL inside MyBatis tags: <select>, <insert>, <update>, <delete>, <sql>, <if>, <where>, <foreach>, <set>, <trim>, <choose>, <when>, <otherwise>, etc.
  • Supports both plain text and <![CDATA[...]]> SQL content
  • Recognizes MyBatis parameter expressions: #{param}, ${param}
  • Configurable comma position, keyword case, and indentation

Usage

Open any .xml file and run Format Document (Shift + Alt + F on Windows/Linux, Shift + Option + F on macOS).

If VS Code asks which formatter to use, select BSPS MyBatis Formatter.

To set BSPS MyBatis Formatter as the default formatter for XML files, add the following to your settings.json:

{
    "[xml]": {
        "editor.defaultFormatter": "boksepyeonsal-dev.bsps-mybatis-formatter"
    }
}

Configuration

All settings are available under Settings > Extensions > BSPS MyBatis Formatter or in settings.json.

mybatis-formatter.commaPosition

Controls where commas appear in column/value lists.

Value Description Example
"after" (default) Trailing comma at end of line a, → next line
"before" Leading comma at start of line , b on each line

"after" (trailing)

SELECT
  user_id,
  user_name,
  email
FROM users

"before" (leading)

SELECT
  user_id
  , user_name
  , email
FROM users

mybatis-formatter.keywordCase

Controls the casing of SQL keywords.

Value Description Example
"upper" (default) Uppercase keywords SELECT, FROM, WHERE
"lower" Lowercase keywords select, from, where
"preserve" Keep original casing unchanged

mybatis-formatter.indentation

The indentation string used for XML and SQL formatting.

Value Description
" " (default) 4 spaces
" " 2 spaces
"\t" Tab

Example settings.json

{
  "mybatis-formatter.commaPosition": "before",
  "mybatis-formatter.keywordCase": "upper",
  "mybatis-formatter.indentation": "    "
}

Example

Before formatting:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.UserMapper">
  <select id="findUser" resultType="User">
    select u.user_id, u.user_name, u.email from users u where u.user_id = #{userId} and u.status = 'ACTIVE'
  </select>
</mapper>

After formatting (commaPosition: "after")

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.UserMapper">
    <select id="findUser" resultType="User">
        SELECT
            u.user_id,
            u.user_name,
            u.email
        FROM users u
        WHERE
            u.user_id = #{userId}
            AND u.status = 'ACTIVE'
    </select>
</mapper>

After formatting (commaPosition: "before")

<select id="findUser" resultType="User">
    SELECT
        u.user_id
        , u.user_name
        , u.email
    FROM users u
    WHERE
        u.user_id = #{userId}
        AND u.status = 'ACTIVE'
</select>
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft