Replace selected text or word under cursor when selection changes (immediate) or when calling a command (by key binding).
This extension looks a lot like Replace Rules by bhughes339.
The difference is the possibility of immediate replacement and change of word under cursor (next version).
The search must match the selected text (for a particular Multi Cursor) completely. If you want to search for a partial match you have to add
(.*?) to the start and end of the search string. If you don't need these strings in the replace string you can use
If a rule is an
immediate rule it is evaluated the moment you Double Click or Select Word or another means of modify the selection.
The rules not marked as
immediate are evaluated when you call the command
replace-on.selection-changed from the command menu as Replace On: Replace selection/word by defined rules or with a key binding. In a key binding you can add an
args property. The
args property has the same format as the
replace-on.selection-changed configuration setting.
If you have Multi Cursors each selection is treated separately.
You specify the search/replace strings in the configuration setting
The properties of
"all": an object with search/replace rules that are applied to all languageIds
"languageId": an object with search/replace rules that are applied only to files with the given languageId
The rules you add for a specific languageId replace rules from the
all section with the same search string.
Be aware that the settings from User, Workspace and Folder are merged. If you redefine a search string the properties are merged for that search string. You may need to add a property with its default value.
Object with search/replace rules
The object with search/replace rules has the following format:
If you define the
- only the
"withKey" properties are used.
- it implies:
"cycle" property is kind of syntax sugar. It generates a set of rules behind the scene you could have defined yourself.
"withKey" property determines if the object key is part of the cycle. If you start with a placeholder string but do not want that string in the cycle use:
"cycle": ["Foo", "Bar"],
Is equivalent with:
- replace current "word" on command (use all rules)