sponsor Vim development Vim logo Vim Book Ad

ChangeGloballySmartCase : Change {motion} text and repeat as SmartCase substitution.

 script karma  Rating 1/1, Downloaded by 166    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) plugin (version 1.20 or higher)
- SmartCase.vim (vimscript #1359)
- repeat.vim (vimscript #2136) plugin (optional)
- visualrepeat.vim (vimscript #3848) plugin (version 2.00 or higher; optional)
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
ChangeGloballySmartCase-1.20.vmb.gz 1.20 2013-11-19 7.0 Ingo Karkat - Adapt to interface changes of ChangeGlobally.vim version 1.20
- Use optional visualrepeat#reapply#VisualMode() for normal mode repeat of a visual mapping. When supplying a [count] on such repeat of a previous linewise selection, now [count] number of lines instead of [count] times the original selection is used.
ChangeGloballySmartCase-1.00.vmb.gz 1.00 2012-11-23 7.0 Ingo Karkat Initial upload
ip used for rating: 54.211.180.175

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
SourceForge.net Logo