ChangeGloballySmartCase : Change {motion} text and repeat as SmartCase substitution.
| script karma |
Rating 0/0,
Downloaded by 46
|
Comments, bugs, improvements
|
Vim wiki
|
| created by |
| Ingo Karkat |
| |
| script type |
| utility |
| |
| description |
DESCRIPTION
As an add-on to the ChangeGlobally.vim plugin (vimscript #4321), this plugin
implements a gC variant that uses a "smart case" substitution which covers
variations in upper-/lowercase ("maxSize" vs. "MaxSize") as well as different
coding styles like CamelCase and underscore_notation ("maxSize", "MAX_SIZE").
The gC command works just like built-in c, and after leaving insert mode
applies the local substitution to all other occurrences (according to the
SmartCase-rules) in the current line (in case of a small character change)
or, when entire line(s) where changed, to the rest of the buffer.
This is especially useful for variable renamings and all the other small
tactical edits that you're doing frequently. It is much faster than doing a
single change and repeating it, or building a :substitute command,
especially since you would have to repeat that for all text variants that
SmartCase covers.
USAGE
[N]["x]gC{motion} Like gc, but also substitute close textual variants
{Visual}[N]["x]gC of the changed text according to the SmartCase-rules:
- variations in upper-/lowercase
("maxSize" vs. "MaxSize")
- different coding styles like CamelCase and
underscore_notation ("maxSize", "MAX_SIZE")
["x]gCC Like gcc, but with SmartCase-rules. It's probably
less useful than gC, but added for completeness.
EXAMPLE
Suppose you have a line like this, and you want to rename the type from
"NodeList" to "FooBarSet", and adapt the variable name, too:
function set nodeList(nodeList:NodeList):void; // Update node list.
With the cursor on the start of any of the "nodeList", type gCe, enter the
text "fooBarSet", then press <Esc>. The line will turn into
function set fooBarSet(fooBarSet:FooBarSet):void; // Update foo bar set.
You can now re-apply this substitution to other lines or a visual selection
via . |
| |
| install details |
INSTALLATION
This script is packaged as a vimball. If you have the "gunzip" decompressor
in your PATH, simply edit the *.vmb.gz package in Vim; otherwise, decompress
the archive first, e.g. using WinZip. Inside Vim, install by sourcing the
vimball or via the :UseVimball command.
vim ChangeGloballySmartCase*.vmb.gz
:so %
To uninstall, use the :RmVimball command.
DEPENDENCIES
- Requires Vim 7.0 or higher.
- ChangeGlobally.vim (vimscript #4321)
- SmartCase.vim (vimscript #1359)
- repeat.vim (vimscript #2136) plugin (optional)
- visualrepeat.vim (vimscript #3848) plugin (optional) |
| |
script versions (upload new version)
Click on the package to download.
ip used for rating: 54.234.67.55
|