Skip to content

A Visual Studio Code extension to automatically close open braces, brackets, or parentheses in the right order.

License

Notifications You must be signed in to change notification settings

cpulvermacher/close-any-bracket

Repository files navigation

Close Any Bracket

Latest Release Installs Status License

A Visual Studio Code extension to automatically close open braces, brackets, or parentheses in the right order.

Demo

You may find this particularly useful with callback-heavy languages or frameworks (e.g. jest, vitest) or in conjunction with Copilot tools that are inconsistent in the amount of context they close at the end of a completion.

Features

  • Close all open brackets to current indent - Automatically closes all unclosed (, [, or { at the current line's indentation level or deeper. (Default shortcut: Alt+Shift+Enter, Mac: Control+Shift+Enter)
  • Close last open (, [, or { - Closes the most recently opened (, [, or { that has not been closed yet. (Default shortcut Alt+], Mac: Control+])
  • Detects whether brackets are already closed after the cursor and avoids closing them again. (Configurable using Close Any Bracket: Ignore Already Closed, default: enabled)
  • Supports close to 300 languages including JavaScript, TypeScript, CSS, JSON, Python, Java, Go, C/C++/C#, HTML (with embedded JavaScript or CSS), Nix, TeX, Awk, JSX, TSX, Vue, Svelte.

Limitations

  • Brackets are inserted at the cursor position without any regard for aesthetics, so this works best if combined with automatic formatting.
  • Some nested structures like template strings may not work well, in particular if the syntax is not valid while you're editing.