Click here to Skip to main content
15,885,309 members
Articles / Desktop Programming / MFC
Article

SmartReplace AddIn [VC 6.0]

Rate me:
Please Sign up or sign in to vote.
4.62/5 (16 votes)
23 Aug 20033 min read 68.5K   2K   32   9
Yet another replace dialog

Image 1

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


    Written By
    Web Developer
    Germany Germany
    This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

    Comments and Discussions

     
    GeneralProblems Pin
    Ron Weigel17-Sep-03 4:54
    Ron Weigel17-Sep-03 4:54 
    GeneralRe: Problems Pin
    Roman Keskenti [SmoCoder]17-Sep-03 7:00
    Roman Keskenti [SmoCoder]17-Sep-03 7:00 
    GeneralConfiguration Control Integration Pin
    ayreon5-Aug-03 21:30
    ayreon5-Aug-03 21:30 
    GeneralRe: Configuration Control Integration Pin
    Roman Keskenti [SmoCoder]6-Aug-03 1:21
    Roman Keskenti [SmoCoder]6-Aug-03 1:21 
    GeneralI like the design... Pin
    Paul Selormey2-Aug-03 16:58
    Paul Selormey2-Aug-03 16:58 
    GeneralFeatures Pin
    Igor Okulist2-Aug-03 10:20
    Igor Okulist2-Aug-03 10:20 
    GeneralRe: Features Pin
    Roman Keskenti [SmoCoder]2-Aug-03 11:36
    Roman Keskenti [SmoCoder]2-Aug-03 11:36 
    GeneralRe: Features Pin
    Igor Okulist23-Jan-04 0:07
    Igor Okulist23-Jan-04 0:07 
    GeneralRe: Features Pin
    Igor Okulist23-Jan-04 0:27
    Igor Okulist23-Jan-04 0:27 

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

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