Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>Py Block WrapNew to Visual Studio Code? Get it now.
Py Block Wrap

Py Block Wrap

Luis Navarro

|
4 installs
| (0) | Free
Wrap selected lines (or the current line) with a Python banner and prefix each line with '# '. Eclipse/PyDev Cmd+4 vibes for VS Code.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Py Block Wrap

Eclipse/PyDev-style Cmd+4 for Python in VS Code:

  • Wrap selected lines with banner lines and prefix each with #
  • With no selection, wraps the current line
  • Keeps surrounding code untouched (no sticky parentheses or extra blank lines)

Usage

  1. Open a Python file
  2. Select lines (or place the cursor on a single line)
  3. Press Cmd+4 (Mac) or remap to your favorite keybinding

Command

  • pyBlockWrap.wrap — Wrap with Python Banner

🪄 Example

Before

from datetime import datetime,timedelta,date
import numpy as np
from glob import glob

After pressing Cmd+4

from datetime import datetime,timedelta,date
####################################################################################
# import numpy as np
####################################################################################
from glob import glob

Default Keybinding

macOS:

{ "command": "pyBlockWrap.wrap", "key": "cmd+4", "when": "editorTextFocus && editorLangId == 'python'" }

Windows/Linux (suggested alternative):

{ "command": "pyBlockWrap.wrap", "key": "ctrl+4", "when": "editorTextFocus && editorLangId == 'python'" }

Local Install from VSIX

  1. Package

    npx @vscode/vsce package
    

    This creates a file like py-block-wrap-0.0.1.vsix.

  2. Install

    • GUI:
      VS Code → Extensions view → ⋯ menu → Install from VSIX… → select the .vsix
      
    • CLI:
      code --install-extension ./py-block-wrap-0.0.1.vsix
      
  3. Verify

    • Open a .py file in your normal VS Code
    • Use Cmd + 4 or Command Palette → Wrap with Python Banner
  4. Uninstall (optional)

    • GUI:
      Extensions → find Py Block Wrap → Uninstall
      
    • CLI:
      code --uninstall-extension your-publisher-id.py-block-wrap
      

Troubleshooting

  • Cmd + 4 does nothing / opens editor #4
    • Keybinding conflict with default “Open editor at index 4”
    • Fix (optional): add this to your user keybindings to remove the default
      { "key": "cmd+4", "command": "-workbench.action.openEditorAtIndex4" }
      
  • Command doesn’t trigger in non-Python files
    • By design, the default keybinding only applies when editorLangId == 'python'
    • You can broaden or change the condition in package.json if desired

Icon & Attribution

Coding icons created by Edwinp99 from Flaticon

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft