writable_search.vim : Perform a grep and edit the results directly
script karma |
Rating 0/0,
Downloaded by 1424 |
Comments, bugs, improvements
|
Vim wiki
|
created by |
Andrew Radev |
|
script type |
utility |
|
description |
Github project: https://github.com/AndrewRadev/writable_search.vim
The plugin exposes the command `:WritableSearch`, which takes a search query and performs a grep (or ack, or a different search command -- see below), with that query. For example:
:WritableSearch function_call\(
The results are opened in a new tab (by default), and are very similar to what you would get from performing the search on the command-line. The difference is that you can now edit this buffer and, upon writing, the original files will be updated with the changes. This gives you a very simple and straightforward search-and-replace process.
If you change the filenames in the header blocks, those files will be renamed (with some manual confirmation that you can turn off if you're feeling adventurous). For example, if the header says:
foo/bar.txt:12-34
and you change that to:
foo/renamed.txt:12-34
Then the file "foo/bar.txt" will be renamed to "foo/renamed.txt". If this is not possible, you'll get an error.
If you change the line numbers displayed in the headers, the virtual "window" that this search result is pointing to will reposition itself to those line numbers. For example, if the header says:
foo/bar.txt:12-34
and you change that to:
foo/bar.txt:10-22
Then the lines displayed will now be the ones from 10 to 22.
The plugin uses "egrep" by default, but can also use "ack", and it can piggyback on the "ack.vim" plugin. For more control, it can also take an existing buffer with some search results and turn them into the writable search buffer. Take a look at the documentation to learn more.
|
|
install 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/writable_search.vim.git ~/.vim/bundle/writable_search
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/writable_search.vim.git bundle/writable_search
Another way is to simply copy all the essential directories inside the ~/.vim directory: autoload, doc, ftplugin, plugin, syntax. |
|
script versions (upload new version)
Click on the package to download.
ip used for rating: 142.132.191.50
|