Skip to content

PeterJCLaw/vscode-tuck

Repository files navigation

VSCode Tuck

CircleCI

VSCode extension for tuck -- semi-automated Python formatting.

Install

Install from the Extension Marketplace using this extension's full name: peterjclaw.tuck.

Features

This extension current provides a single command, equivalent to calling tuck against the current file and using the cursor position as the position to wrap.

The command can most easily be run using the keyboard shortcut Alt+Shift+W.

Examples

Function definition

Place cursor on foo or within the parentheses, then run the command:

def foo(bar: str, quox: int = 0) -> float:
    return 4.2

wraps to:

def foo(
    bar: str,
    quox: int = 0,
) -> float:
    return 4.2

List comprehension

Place cursor on for, then run the command:

[x for x in 'aBcD' if x.isupper()]

wraps to:

[
    x
    for x in 'aBcD'
    if x.isupper()
]

Release Notes

See CHANGELOG.md.

Attribution

Tuck uses asttokens to aid its handling of the Python AST. asttokens is included in the extension, licensed under Apache 2.0.