Skip to content

avivey/vscode-quick-new-file

Repository files navigation

Quick New File: A VSCode Extension

Quicker way to create a new file (that looks like the current one).

Features

Hit ctrl+shift+N to create a new file that has the same context as the current one:

  • Same extension and directory
  • Same package declaration (where applicable)
  • Same imports
  • Same hashbang (#!) string (also, chmod +x)
  • Boilerplate code (where applicable)

Supported Languages

  • Go (Package, imports and build constraints)
  • Java (Package, imports and class boilerplate)
  • PHP (<?php)
  • Python (Imports)
  • Shellscript (set and source statement)

⚡NEW⚡ Extensions

Other extensions can now provide their own "New File" template/generator - useful for project-specific conventions.

To extend, add something like this to your extension:

export async function register(context: vscode.ExtensionContext) {
    const ext = vscode.extensions.getExtension('avive.quick-new-file');
    if (!ext) {
        return;
    }
    let api = await ext.activate();

    maker1 = {
        createNewContent(runner) {
            return "new body goes here";
        }
    }

    provider = {
        maker(reference: vscode.TextDocument) {
            return maker1;
        }

        order() { return 666; }
    }

    api.registerFileMakerProvider(provider);
}

The src/definitions/quick-new-file.d.ts file has more precise definitions.

About

Quicker way to create a new file (that looks like the current one)

Resources

License

Stars

1 star

Watchers

1 watching

Forks

Contributors