VS Code Auto Align: Shortcuts, Settings, and Best Practices
Updated Jul 2026
Some links on this page are affiliate links. If you buy through them we may earn a small commission at no extra cost to you. We only recommend what we'd use.
- Vertical alignment in VS Code requires third-party extensions like Better Align or Align
- Custom keybindings like Alt+A speed up multi-line assignment formatting
- Config settings in settings.json allow custom regular expressions for lining up symbols
- Use vertical alignment intentionally on localized code blocks to avoid unnecessary Git diff noise

VS Code Auto Align: Shortcuts, Settings, and Best Practices
Auto alignment in Visual Studio Code relies on community extensions like Better Align or Align by Felix Rieseberg, as the core editor does not include native vertical symbol alignment out of the box.
Understanding Auto Alignment in VS Code
Auto alignment in VS Code vertically formats code elements like assignment operators, object keys, array values, and comments across consecutive lines. Because VS Code lacks built-in vertical alignment features, developers rely on third-party extensions that scan selected text using regular expressions and automatically insert precise space padding to line up matching characters.
Standard editor formatters like Prettier or VS Code's built-in Shift+Alt+F shortcut handle general indentation and bracket spacing, but they deliberately avoid vertical character lining. Formatter maintainers usually skip vertical alignment because changing a single variable name later forces space adjustments across every adjacent line. However, for large configuration objects, variable declarations, and mapping tables, lining up equal signs (=) or colons (:) makes long blocks of code substantially easier to scan during code reviews.
Essential Auto Align Shortcuts

Most VS Code auto-align extensions do not map a default global keyboard shortcut out of the box to prevent keybinding conflicts. Instead, you trigger alignment by selecting lines and running the command through the Command Palette (Ctrl+Shift+P on Windows/Linux or Cmd+Shift+P on macOS) or by setting up a custom hotkey.
Because opening the Command Palette every time slows down editing, mapping a dedicated key combination is standard practice. To set up your own trigger:
- Press
Ctrl+K Ctrl+S(orCmd+K Cmd+Son macOS) to open the Keyboard Shortcuts menu. - Search for your installed alignment extension's command (for example,
Better AlignorAlign Selection). - Click the plus sign next to the command, press your preferred key combination (such as
Alt+AorCtrl+Alt+A), and hit Enter.
Once bound, highlight any multi-line block of assignments and press your shortcut to organize the block instantly.
Popular Auto Align Extensions and Setup
The most popular VS Code alignment extensions are Better Align, Align (by Felix Rieseberg), and Align Assignments. Better Align excels at automatically detecting colons and assignment operators in real time, while Felix Rieseberg’s Align provides powerful regular-expression matching for custom tabular layouts across various programming languages.
Depending on your language stack and formatting requirements, specific tools work better than others:
- Better Align: Automatically detects assignment operators (
=,+=,-=), object keys (:), arrow functions (=>), and trailing comments. It aligns highlighting selection without requiring manual regex prompts. - Align (Felix Rieseberg): A flexible choice for custom alignment. When invoked, it lets you enter any character or custom regular expression, making it useful for aligning obscure symbols, pipe characters in Markdown tables, or custom SQL queries.
- Align Assignments: A lightweight tool focused purely on variable declarations in JavaScript, Python, PHP, and C-style languages. It ignores object keys and concentrates strictly on variable assignment operators.
Customizing Auto Align Settings in settings.json
You can customize alignment behavior by tweaking extension settings directly inside your VS Code settings.json file. These settings control space buffering, operator mapping, and custom regex expressions, allowing you to determine exactly which characters get aligned and how many spaces surround each operator.
To access these settings, open the Command Palette and select Preferences: Open User Settings (JSON). You can append specific configuration keys depending on your extension. For instance, if you use Better Align, you can adjust space padding and token behaviors like this:
{
"betterAlign.surroundSpace": {
"assignment": [1, 1],
"colon": [0, 1],
"arrowFunction": [1, 1]
},
"betterAlign.operatorPattern": ":|=|=>|\\+="
}
Configuring these rules ensures that your alignment choices match your team's code style, avoiding extra spaces where your linter might complain.
Troubleshooting Common Alignment Issues
When auto alignment fails, the culprit is usually a keybinding conflict, unselected text lines, or interference from auto-formatters like Prettier. Resolving alignment errors involves highlighting target lines explicitly, auditing active keyboard shortcuts for overlapping commands, and disabling format-on-save for files requiring custom vertical spacing.
If your alignment triggers aren't responding properly, work through these diagnostic checks:
- Highlight exact line ranges: Most alignment extensions require an active multi-line text selection. Highlight the target block completely before hitting the shortcut.
- Check for conflicting hotkeys: Search the Keyboard Shortcuts menu for your key combination to verify another extension isn't capturing the same input.
- Manage format-on-save overrides: If aligned code resets the moment you save the file, an automated formatter like Prettier is likely undoing the spacing. Add
// prettier-ignoreabove the block, or adjust your workspace linter rules. - Verify mixed indentation: Mixing tabs and spaces on the same lines can confuse character positioning calculation algorithms, leading to offset columns.
Comparison of Top VS Code Alignment Extensions
Selecting the right VS Code alignment extension depends on whether you need quick automatic operator lining or precise regex control. Extensions differ in setup complexity, language flexibility, and background performance, with basic plugins focusing on variable assignments and advanced tools supporting multi-column tabular alignment across complex data structures.
| Tool | Best For | Setup Complexity | Standout Feature |
|---|---|---|---|
| Better Align | Daily code cleanup, object literals | Low (Works out-of-the-box) | Automatic operator recognition |
| Align (Felix Rieseberg) | Markdown tables, custom symbols | Medium (Requires prompt input) | Custom regex character alignment |
| Align Assignments | Variable assignment blocks | Low (Single command) | Lightweight footprint |
🛍 Ready to buy? Check current prices on Amazon for the picks in this guide.
For most developers, Better Align offers the smoothest day-to-day balance of automation and speed. If you regularly work with custom text formats or markdown data, Align by Felix Rieseberg provides broader manual utility.
Best Practices for Clean Code Alignment
Vertical code alignment should be used selectively on variable lists, object literals, and dictionary blocks rather than entire source files. Indiscriminate auto-alignment can create noisy version control diffs, forcing Git to flag dozens of unchanged lines simply because a single long variable name shifted adjacent operator spacing.
To keep codebases clean and team-friendly, keep these practical tips in mind:
- Align localized blocks only: Limit vertical alignment to distinct blocks of similar assignments or dictionary keys rather than running it across whole files.
- Keep version control clean: Be mindful of shared repositories. Re-aligning twenty lines just to add one variable can make Git history and pull requests harder for teammates to review.
- Coordinate with team linters: Ensure your vertical alignment spacing settings align with your project's ESLint, Black, or Stylelint rules so saving the file doesn't trigger automated linting errors.
FAQ
How do I install a VS Code auto align extension?
Open VS Code, press Ctrl+Shift+X (or Cmd+Shift+X on macOS) to open the Extensions view, search for your chosen alignment tool—such as "Better Align"—and click Install. Once installed, the extension is instantly ready to use without restarting the editor.
Can I set up a custom keybinding for code alignment?
Yes. Open the Command Palette, type "Keyboard Shortcuts", and select Preferences: Open Keyboard Shortcuts. Search for your extension's align command (like Better Align), double-click it, press your preferred key combination (such as Alt+A), and hit Enter to save.
Why does Prettier undo my code alignment on save?
Prettier intentionally strips vertical alignment to maintain strict style rules and minimize git diff clutter. To keep custom alignment intact, you can disable editor.formatOnSave for specific languages or add target files to a .prettierignore file in your workspace.
Is auto alignment supported natively in VS Code without extensions?
No, standard VS Code includes code formatting (Shift+Alt+F), but lacks built-in vertical alignment for lining up equal signs or colons across multiple lines. You must install a third-party extension to unlock vertical character alignment functionality.
Does code alignment affect application performance or file size?
No. Code alignment only adds space characters before operators, which modern language parsers ignore. Compilers, minifiers, and interpreters strip extra whitespace during build processes, ensuring zero impact on your production application's speed or final bundle size.
🛍 See today's best prices on Amazon and grab the option that fits you.