writable_search.vim : Perform a grep and edit the results directly
| script karma
Downloaded by 257
Comments, bugs, improvements
script versions (upload new version)
|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:
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:
and you change that to:
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:
and you change that to:
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.
|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.
Click on the package to download.
ip used for rating: 18.104.22.168