sponsor Vim development Vim logo go to HTTPS page Vim Book Ad

writable_search.vim : Perform a grep and edit the results directly

 script karma  Rating 0/0, Downloaded by 362    Comments, bugs, improvements  Vim wiki

created by
Andrew Radev
script type
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:


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.
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.

Rating scripts is only available on the HTTPS page

script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
writable_search.zip 0.2.0 2015-01-27 7.0 Andrew Radev Configurable backends, like: ack, git-grep, egrep. Possible to, for example, set up "ack" as default, but use "git-grep" if we're in a git repository.
writable_search.zip 0.1.0 2014-02-15 7.0 Andrew Radev Initial upload
ip used for rating:

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