Code Monkey home page Code Monkey logo

vscode-complete-statement's Introduction

Complete Statement with semicolon in vscode.

Mimic IntelliJ's complete statement. In other words:

  • Complete normal statement with ;, insert a newline and move down.
  • Try to complete complex structures with braces.

Works with languages with a C style syntax.

Status

This project is orphaned. I switched to Neovim as my mainly used editor. I still use vscode occasionally, but for languages not requiring a semicolon to end a statement.

Pull requests are still welcome, though. And if you want to maintain this project, please open an issue or send a pull request, I will add you to the collaborators of the source code repository.

Install

The version on marketplace is outdated. Please use the version on open-vsx.org (vscodium uses open-vsx by default). You can also download the vsix file at GitHub releases page, and manually install it via "vscode > Extensions > Install from VSIX...".

If you want to try the cutting-edge version (master), you can clone this repository, and package it yourself:

npx vsce package

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+;`
let semicolon: string = "already exist";
][
function works_too(para: number][)
// `ctrl+;`
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 in most languages with a C like style, such as JavaScript, Java, Ceylon, and C itself. This extension also works in languages like Kotlin, Scala, Swift, and so on. But I recommend you only use it to complete complete structures, not single statement since it will append a semicolon (;) at the end.

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

  • This extension does not understand semantics of programming languages. So complete structure may not work as you expected.

    For example, it cannot completes if with multiple line conditions. The "parsing" is very naive, only covering limited conditions.

  • Indented with tab is not supported yet. Pull request is welcome.

License

0BSD

vscode-complete-statement's People

Contributors

dependabot[bot] avatar rrad42 avatar weakish avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

vscode-complete-statement's Issues

trailing comma idea

firstly, thank you so much.
i'm the on who recently moved from atom to vscode as atom is way too slow.
and there was some feature in some atom package that adds comma at the end of code line.

it is very useful when writing objects in javascript or typescript.

i'll try my best to implement this feature on my own, but i hope not you get angry after my fuzzy code. (since i'm not that familiar with typescript)
anyway, thank you again!

Auto append closing paren

Not as perfect as intellij's statement completion features. For example in intellij:

console.log('fsdf'

then press complete statement shortcut it will be smart enough to append ");" to the statement. Will be nicer if the extension add more syntax detection

---- Hongzhi Xu, 12/20/2017

[BUG] Adding newline character to the end

The latest version of the extension from GitHub still has newline character problem. Upon pressing ctrl+; , along with adding statement terminator ; a newline character also gets added every time.

Open VSX Listing: Signing the Publisher Agreement

Thank you for being part of the Open VSX community by adding your extensions to the Open VSX Registry. Please note that the service was recently transferred to the Eclipse Foundation and urgent action on your part is needed so we can continue to list your extensions. To ensure uninterrupted service, please sign the Eclipse Publisher Agreement as soon as possible.

Regrettably, if not soon, your extensions will be delisted and will no longer appear on the site nor be available via the API. If you sign at a later date, your extensions will then be re-activated. The signing process is explained in the Wiki (steps 1 and 2).

Please also note that all extensions MUST have a license in order to be listed.

Claiming ownership of the namespace for your extension(s): We also recommend you do this. To find out how to do this, see:
https://github.com/eclipse/openvsx/wiki/Namespace-Access

Useful links:
Eclipse Publisher Agreement
Eclipse Foundation Open VSX Registry Frequently Asked Questions (FAQ)

More details are in these recent blog posts:
https://blogs.eclipse.org/post/brian-king/open-vsx-registry-under-new-management
https://blogs.eclipse.org/post/brian-king/new-era-open-vsx-registry

Today, there’s growing momentum around open source tools and technologies that support Visual Studio (VS) Code extensions. Leading global organizations are adopting these tools and technologies. This momentum has spurred demand for a marketplace without restrictions and limitations. Thanks for joining us on this journey as we continue to build the Open VSX community.
We look forward to continued innovation from you in 2021!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.