multichange.vim : Edit a word and have the change propagate throughout the buffer
| script karma
Downloaded by 402
Comments, bugs, improvements
script versions (upload new version)
|Github project: https://github.com/AndrewRadev/multichange.vim
The plugin exposes a command, :Multichange, that enters a special "multi" mode. In this mode, any change of a word with a "c" mapping is propagated throughout the entire file. Example:
def add(one, two):
return one + two
If we wanted to rename the "one" parameter to "first" and the "two" parameter to "second", we could do it in a number of ways using either the . mapping or substitutions. With multichange, we execute the :Multichange command, and then perform the cw operation on "one" and "two" within the argument list. Changing them to "first" and "second" will be performed for the entire file.
Note that this works similarly to the * mapping -- it replaces words only, so it won't replace the "one" in "one_more_thing".
To exit "multi" mode, press <esc>. To limit the "multi" mode to only an area of the file (for example, to rename variables within a single function definition), select the desired area and then execute :Multichange.
You can also make a change in visual mode. For example, you want to change a function name in Vimscript:
Since : is not in iskeyword (I think), you might have problems changing the function name using word motions. In this case, start "multi" mode as described above, then mark s:BadName in characterwise visual mode (with v). After pressing c, change the name to whatever you like. This will propagate the same way as the word change from before. The difference is that whatever was selected will be changed, regardless of word boundaries. So, if you only select "Name" and change it, any encounter of "Name" will be replaced.
The plugin also exposes a mapping for the :Multichange command that acts as a text object. Read the documentation for more details.
|There are several ways to install the plugin. The recommended one is by using Tim Pope's pathogen (http://www.vim.org/scripts/script.php?script_id=2332). In that case, you can clone the plugin's git repository like so:
git clone git://github.com/AndrewRadev/multichange.vim.git ~/.vim/bundle/multichange
If your vim configuration is under git version control, you could also set up the repository as a submodule, which would allow you to update more easily. The command is (provided you're in ~/.vim):
git submodule add git://github.com/AndrewRadev/multichange.vim.git bundle/multichange
Another way is to simply copy all the essential directories inside the ~/.vim directory: autoload, doc, plugin.
Click on the package to download.
ip used for rating: 126.96.36.199