vscode-complete-statement

Complete Statement with semicolon, comma or braces in vscode.

Mimic IntelliJ’s complete statement. In other words:

Works with languages with a C style syntax.

Install

The version on marketplace is outdated. Please download the vsix file at GitHub releases page, and manually install it via vscode > Extensions > Install from VSIX…

Key binding

This extension uses ctrl+; (cmd+; on mac) since vscode already uses ctrl+shift+enter.

You can rebind extension.complete-statement to ctrl+shift+enter.

BTW, ctrl+; is easier to remember and type than ctrl+shift+enter. I myself use ctrl+enter since ctrl+; is hard to type in dvorak.

Example

We use ][ to represent cursor.

][
let a_number = 2][ # decide to specify type
let a_number: number][ = 2
// press `ctrl+;` (`cmd+;` on mac)
let a_number: number = 2;][
let semicolon: string][ = "already exist";
// `ctrl+;` will insert an new blank line
let semicolon: string = "already exist";][

function works_too(para: number][)
// `ctrl+;`
function works_too(para: number) {][

}
// press `ctrl+;` again or `down` arrow key
function works_too(para: number) {
    ][
}
// Respects `tabSize` setting. If `tabSize` unset, use 4 spaces.
function works_too(para: number) {
    if (a_number == 1][)
}
// `ctrl+;`
function works_too(para: number) {
    if (a_number == 1) {][

    }
}

The above example uses TypeScript, but this extension works under most languages with a C like style, such as JavaScript, Swift, Kotlin, Scala, Java, Ceylon, and C itself.

Configuration

By default, complete-statement uses Java style (beginning brace on same line). To use Allman style (beginning brace on its own line), add the following line in settings:

    "complete-statement.allman": true

Bugs

License

0BSD