🚀 Add Smart Prefix/Suffix with regex

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
- Open VS Code
- Go to Extensions (
Ctrl+Shift+X
)
- Search for "Add Smart Prefix/Suffix with regex"
- Click Install
2. Basic Usage
- Select files or folders in the explorer
- Right-click and choose "Add Smart Prefix/Suffix with regex"
- Enter your regex pattern
- Choose prefix or suffix
- 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+"
}
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
- Open VS Code
- Press
Ctrl+Shift+X
- Search for "Add Smart Prefix/Suffix with regex"
- 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
- Open the project in VS Code
- Press
F5
to launch extension host
- Test the extension in the new window
🤝 Contributing
We welcome contributions! Please see our Contributing Guide for details.
Development Workflow
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
)
- Make your changes
- Run tests (
npm run test
)
- Commit your changes (
git commit -m 'Add amazing feature'
)
- Push to the branch (
git push origin feature/amazing-feature
)
- 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