Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Add Smart Prefix/Suffix with Regex SPNew to Visual Studio Code? Get it now.
Add Smart Prefix/Suffix with Regex SP

Add Smart Prefix/Suffix with Regex SP

SMIT_PATEL_SP

|
3 installs
| (0) | Free
Add smart prefixes or suffixes to lines matching specific regex patterns with customizable formatting options
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

🚀 Add Smart Prefix/Suffix with regex

Version VS Code License

Smart, powerful, and customizable - Add intelligent prefixes or suffixes to lines matching specific regex patterns with advanced formatting options.

✨ Features

🎯 Core Functionality

  • 🔍 Smart Regex Matching: Use any regex pattern to match lines with real-time validation
  • 📝 Prefix/Suffix Support: Add content at the beginning or end of matching lines
  • 📁 Multi-Format Processing: Handle single files, multiple files, or entire folders
  • ⚡ Intelligent Detection: Automatically detects file types and adapts behavior

🎨 Advanced Features

  • 🔄 Auto-Formatting: Smart formatting with user preference control (Yes/No/Ask)
  • ⚙️ Customizable Settings: Configure default values and behavior
  • 📊 Progress Tracking: Real-time progress with percentage completion
  • 🎛️ User Preferences: Persistent settings for regex, prefixes, and suffixes

🛠️ Developer Experience

  • 🚀 One-Click Operation: Single command handles all scenarios
  • 📈 Visual Feedback: Progress notifications and status updates
  • 🔧 Flexible Configuration: Workspace and user-level settings
  • 🎯 Context-Aware: Adapts to your selection (files/folders)

🚀 Quick Start

1. Install the Extension

  1. Open VS Code
  2. Go to Extensions (Ctrl+Shift+X)
  3. Search for "Add Smart Prefix/Suffix with regex"
  4. Click Install

2. Basic Usage

  1. Select files or folders in the explorer
  2. Right-click and choose "Add Smart Prefix/Suffix with regex"
  3. Enter your regex pattern
  4. Choose prefix or suffix
  5. Configure options and let it work!

📖 Detailed Usage

Single File Processing

Right-click file → "Add Smart Prefix/Suffix with regex"

Multiple File Processing

Select multiple files → Right-click → "Add Smart Prefix/Suffix with regex"

Folder Processing

Right-click folder → "Add Smart Prefix/Suffix with regex" → Select file types

⚙️ Configuration

Settings

Configure the extension in VS Code settings (Ctrl+,):

{
  "addPrefix.autoFormat": "Ask",        // "Yes", "No", or "Ask"
  "addPrefix.defaultPrefix": "// TODO: ",
  "addPrefix.defaultSuffix": " // TODO",
  "addPrefix.defaultRegex": "^\\s*function\\s+\\w+"
}

Auto-Format Options

Option Behavior
"Yes" Always format files automatically
"No" Never format files automatically
"Ask" Prompt user each time (default)

💡 Examples

🎯 Function Documentation

// Before
function calculateTotal(items) {
    return items.reduce((sum, item) => sum + item.price, 0);
}

// After (with regex: ^\s*function\s+\w+)
// TODO: Add input validation
function calculateTotal(items) {
    return items.reduce((sum, item) => sum + item.price, 0);
}

🐛 Debug Statement Marking

// Before
console.log('User data:', userData);
console.log('Processing complete');

// After (with regex: console\.log\()
// FIXME: Remove debug statements before production
console.log('User data:', userData);
// FIXME: Remove debug statements before production
console.log('Processing complete');

🎨 CSS Component Marking

/* Before */
.user-profile {
    display: flex;
    align-items: center;
}

/* After (with regex: ^\s*\.[a-zA-Z-]+\s*\{) */
/* Component: User Profile */
.user-profile {
    display: flex;
    align-items: center;
}

📝 Line Numbering

// Before
function validateEmail(email: string): boolean {
    const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
    return emailRegex.test(email);
}

// After (with regex: ^\s*function\s+\w+)
function validateEmail(email: string): boolean { // Line: 1
    const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
    return emailRegex.test(email);
}

🔧 Advanced Configuration

Regex Patterns

Pattern Matches Use Case
^\s*function\s+\w+ Function declarations Documentation
console\.log\( Console statements Debug marking
^\s*\.[a-zA-Z-]+\s*\{ CSS selectors Component marking
^\s*export\s+ Export statements Module tracking
^\s*import\s+ Import statements Dependency tracking

File Type Support

  • Web: .html, .css, .scss, .js, .ts, .jsx, .tsx, .vue
  • Data: .json, .xml, .yaml, .yml
  • Documentation: .md, .txt
  • Testing: .spec.ts, .spec.js

🎯 Use Cases

🏢 Enterprise Development

  • Code Review: Mark functions for review
  • Documentation: Add inline documentation
  • Debugging: Mark temporary debug statements
  • Architecture: Mark architectural decisions

🎨 Frontend Development

  • Component Tracking: Mark component boundaries
  • Style Organization: Organize CSS/SCSS
  • Framework Integration: Mark framework-specific code

🔧 Backend Development

  • API Documentation: Mark API endpoints
  • Database Operations: Mark database queries
  • Security: Mark security-sensitive code

🚀 Installation

From VS Code Marketplace

  1. Open VS Code
  2. Press Ctrl+Shift+X
  3. Search for "Add Smart Prefix/Suffix with regex"
  4. Click Install

From Source

git clone https://github.com/your-username/add-smart-prefix-suffix.git
cd add-smart-prefix-suffix
npm install
npm run compile

🛠️ Development

Prerequisites

  • Node.js 16.x or higher
  • VS Code 1.74.0 or higher

Setup

# Install dependencies
npm install

# Compile TypeScript
npm run compile

# Watch for changes
npm run watch

# Run linting
npm run lint

# Run tests
npm run test

Debugging

  1. Open the project in VS Code
  2. Press F5 to launch extension host
  3. Test the extension in the new window

🤝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Workflow

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Run tests (npm run test)
  5. Commit your changes (git commit -m 'Add amazing feature')
  6. Push to the branch (git push origin feature/amazing-feature)
  7. Open a Pull Request

📝 Changelog

See CHANGELOG.md for a complete list of changes.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

  • VS Code team for the excellent extension API
  • The open-source community for inspiration and tools
  • All contributors and users of this extension

📞 Support

  • Issues: GitHub Issues
  • Discussions: GitHub Discussions
  • Email: your-email@example.com

Made with ❤️ for the VS Code community

⭐ Star on GitHub | 📖 Documentation | 🐛 Report Issues

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