Click here to Skip to main content
Click here to Skip to main content

SmartReplace AddIn [VC 6.0]

By , 23 Aug 2003
Rate this:
Please Sign up or sign in to vote.

Introduction

There already are some nice substitutions for the built-in replace dialog available, but none of them entirely satisfied my needs. This is why I've written yet another one.

This AddIn, in contrast to all others I know of, does the actual find and replace operation inside the DevStudio IDE, meaning that each file that gets scanned for replacements is acutally opened as a document. This way you can replace within serveral files and watch the result prior to saving them.

Installation

Simply put the binary into your %MSDevDir%\AddIns folder and enable it in the Tools | Customize | AddIns & Macros dialog.

Usage

The AddIn installs a toolbar icon. Simply click it or add a keyboard shortcut to its command to your profile.

New case option

Here is a brief description of the new option

All Cases

When enabled, the replace command replaces all three cases, i.e. as-is, lower-case and upper-case, of the find string with the same case of the replace string. For instance, if the find string is "Abc" and the replace string is "Def" then "abc" will be replaced with "def", "Abc" will be replaced with "Def" and "ABC" will be replaced with "DEF" while all other cases, e.g. "aBc", remain unchanged.

New replace locations

The new replace locations are enabled by selecting "Extended" in the "Replace where" group. Press the "Advanced" button to show the extended locations options. Here is a brief description of the new replace locations:

All open text files

Replaces all instances of the find string with the replace string in all open text documents.

All text files within current project

Replaces all instances of the find string with the replace string in all text documents belonging to the active project of the workspace.

All text files within current workspace

Replaces all instances of the find string with the replace string in all text documents belonging to either project of the workspace.

All text files in specified directory

Replaces all instances of the find string with the replace string in all files matching the filter provided by the "File Extensions" and "Directory" combo boxes. Check the "Recurse" option to extend the operatio to all sub directories.

All text files matching file and folder filters

Replaces all instances of the find string with the replace string in all files matching the filters provided by the "Filters..." dialog.

Global options

Press the "Options..." button to open the global options dialog

SmartReplace Options

Confirm

Here you can specifiy when to ask your permission for replacement. Available options are: Never, Each Instance, Each File and Each Project. The "Only ask in extended mode" disables the confirmation dialog for the "oridnary" replace locations "Selection" and "Current File".

Documents

Lets you specify when to save and close documents that got modifed during the replace operation. Available modes are: Always, Never and Ask.

File and Folder Filter

Lets you specify the folders and file filters to use with replace location "All files matching file and folder filters".

SmartReplace Filters

Known Bugs

See the ReadMe.txt for Known Bugs and ToDo list.

Implementation

The AddIn incorporates a yet unfinished light-weight DevStudio Automation Model Interface wrapper library that aims at speeding up AddIn Development. Perhaps you might find it useful for your own AddIn projects.

 Updates

SmartReplace 1.2

New Features

  • Added regular expression context menus (thanks to Daniel Beutler [chefsponk] for the code)
  • Moved DSWrapLib to a seperate project
  • SmartReplace 1.1

    New Features

  • Enabled "Regular Expression"
  • Added Browse For Folder Button
  • Browse For Folder dialogs now open at current directory
  • "File Extensions" can now be entered manually
  • "File Mask" now supports multiple filters (i.e. "*.cpp;*.h")
  • Bug Fixes

  • "Cancel"-hang fixed
  • "Continue" and "Replace" now stop atfer all instances have been enumerated
  • "Match Whole Words" now works in all modes execpt "Selection"
  • "Regular Expression" now works in all modes execpt "Selection"
  • License

    This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

    A list of licenses authors might use can be found here

    About the Author

    Roman Keskenti [SmoCoder]
    Web Developer
    Germany Germany
    No Biography provided

    Comments and Discussions

     
    GeneralProblems PinmemberRocketFuMaster17-Sep-03 4:54 
    GeneralRe: Problems PinmemberRoman Keskenti [SmoCoder]17-Sep-03 7:00 
    GeneralConfiguration Control Integration Pinmemberayreon5-Aug-03 21:30 
    GeneralRe: Configuration Control Integration PinmemberRoman Keskenti [SmoCoder]6-Aug-03 1:21 
    I'm sorry, but afaik, there is now way to programatically determine whether a file is checked-in or simply read-only. Even if there was, I haven't seen Source Control interfaces exposed by the DevStudio Automation Object Model - so there is no way to check the files out programatically. Nevertheless, if anybody has an idea on how to solve this problem, I'll give it a try.
     
    My best solution for the moment is: simply check out all files before the replacement and check them back in afterwards.

    GeneralI like the design... PinmemberPaul Selormey2-Aug-03 16:58 
    GeneralFeatures Pinmemberokigan2-Aug-03 10:20 
    GeneralRe: Features PinmemberRoman Keskenti [SmoCoder]2-Aug-03 11:36 
    GeneralRe: Features Pinmemberokigan23-Jan-04 0:07 
    GeneralRe: Features Pinmemberokigan23-Jan-04 0:27 

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

    | Advertise | Privacy | Mobile
    Web04 | 2.8.140415.2 | Last Updated 24 Aug 2003
    Article Copyright 2003 by Roman Keskenti [SmoCoder]
    Everything else Copyright © CodeProject, 1999-2014
    Terms of Use
    Layout: fixed | fluid