Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Smart Replace by RijalNew to Visual Studio Code? Get it now.
Smart Replace by Rijal

Smart Replace by Rijal

Smart Replace

| (0) | Free
Replace Python code blocks with automatic indentation fixing
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

⚡ Smart Replace

Replace code blocks from AI with automatic indentation fixing no more indentation errors, no more wasted tokens.


The Problem

When you ask AI to fix or update part of your code, it usually gives you the new code only. To replace it manually, you have to:

  • Find the exact location in your file
  • Copy it perfectly one wrong space breaks Python
  • Paste the new code with the correct indentation

This wastes time, wastes tokens (asking AI to regenerate), and is easy to get wrong.


The Solution

Smart Replace gives you a panel with 3 simple steps:

  1. Paste AI's old code → click Find & Highlight → it jumps to the exact location in your file and selects it automatically
  2. Ctrl+C from the highlight → paste into box ②
  3. Paste new code from AI → click Replace

Done. Correct indentation, no errors, no regeneration needed.


Requirements

  • VS Code
  • Node.js v16 or higher

Installation

  1. Download smart-replace-0.0.1.vsix
  2. Open VS Code
  3. Open terminal and run:
code --install-extension smart-replace-0.0.1.vsix
  1. Restart VS Code

How to Use

Step 1 Ask AI for both old and new code

This is the key. When asking AI to update your code, always say:

"Give me the full old code block and the new code block separately"

Example prompt:

"Update the calculate function to also handle negative numbers. Give me the full old code and the full new code separately."

AI will give you two blocks old and new. That's all you need.


Step 2 Open Smart Replace

Press Ctrl+Shift+R while your Python file is open.

A panel will appear on the right side with 3 boxes.


Step 3 Find & Highlight

Paste the full old code block from AI into box ①.

Click 🔍 Find & Highlight in File.

Smart Replace will:

  • Search for that code in your file
  • Jump to the exact location
  • Select/highlight it automatically

Step 4 Copy the Highlighted Code

In your file, the code is now highlighted.

Press Ctrl+C to copy it.

Paste it into box ②.

Why this step? The highlighted code has the exact indentation from your file. This ensures the replacement is perfectly aligned.


Step 5 Replace

Paste the new code from AI into box ③.

Click ⚡ Replace with correct indentation.

Done! The code is replaced with correct indentation automatically.


Tips for Best Results

Always ask AI for the full block

The more complete the old code in box ①, the more accurately Smart Replace can find it.

✅ Good full function:

def calculate(x, y):
    if x > 0:
        return x + y
    else:
        return y

❌ Not enough — too short, might match wrong location:

def calculate(x, y):
    if x > 0:

Works with nested code too

Smart Replace handles deeply nested code inside classes and functions. Just make sure to paste the full block.


If "Could not find" error appears

  • Make sure you pasted the complete old code block, not just a few lines
  • Try adding one more line above or below for more context

Keyboard Shortcuts

Shortcut Action
Ctrl+Shift+R Open Smart Replace panel

Tested On

  • ✅ Functions at the top of file
  • ✅ Methods inside classes
  • ✅ Deeply nested code blocks
  • ✅ Two similar function names (replaces correct one)
  • ✅ Long files (100+ lines)

Made by

Rijal Saepuloh — github.com/rijal028

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