Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>Python Refactor Introduce VariableNew to Visual Studio Code? Get it now.
Python Refactor Introduce Variable

Python Refactor Introduce Variable

manhealth

|
188 installs
| (0) | Free
Intelligently assign expressions to variables with smart naming
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Variable Assignment Helper

A VS Code extension that helps you quickly assign expressions to variables with intelligent naming suggestions.

Features

  • Automatically assigns expressions to variables with smart name suggestions
  • Works with the cursor on any line containing an expression
  • Maintains proper indentation
  • Handles comments and whitespace intelligently
  • Supports Python expressions (more languages coming soon)

Usage

  1. Place your cursor on a line containing an expression
  2. Press Ctrl+Shift+A (Windows/Linux) or Cmd+Shift+A (Mac)
  3. The expression will be automatically assigned to a variable with a suggested name

Example

Before:

    print(len([1, 2, 3]))  # your cursor is here

After pressing Ctrl+Shift+A:

    length = len([1, 2, 3])
    print(length)

Smart Naming Rules

The extension suggests variable names based on common programming patterns:

  • List operations → items, list
  • Dictionary operations → dict
  • Length calculations → length
  • Sum operations → total
  • And many more...

Requirements

  • VS Code 1.60.0 or higher

Extension Settings

This extension contributes the following commands:

  • extension.smartAssign: Assign expression to variable with smart naming

Known Issues

None at the moment.

Release Notes

1.0.0

Initial release:

  • Smart variable naming
  • Automatic expression detection
  • Proper indentation handling
  • Comment and whitespace handling
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft