Vim utilities: Findgrep & Fastgrep

I spent some time writing utility scripts for my Vim setup. I figured I can share them here, someone may even find them useful or at least get a laugh out of it. Last time I presented “Impl switcher”, and “Better Tab New” before that. Today it’s Findgrep & Fastgrep’s turn.

I wrote about Fastgrep a long time ago. The idea behind it is to speed up the slowest part in a grep command, the disk seek time, by creating a huge blob file with all the files in a project concatenated.

Fastgrep works great. But it requires a context switch, going from your IDE to your console just to grep. Findgrep fills the gap between the IDE and the command line: this utility provides a few key bindings to let you quickly run some common commands, like searching for a selected string or finding a file in the project directory.

You can get Fastgrep hereFindgrep is available in Github, and you can easily replace Fastgrep with normal grep if you need to.

Advertisements

Vim utilities: Impl switcher

I spent some time writing utility scripts for my Vim setup. I figured I can share them here, someone may even find them useful or at least get a laugh out of it. Last time I presented “BTN: Better Tab New“. Today it’s the turn for “Impl switcher”.

With its very imaginative name, “Impl switcher” has a very obvious purpose: it will just switch from a header file to an implementation file. So, between .h and .cpp. Surely there are lots of Vim plugins to do just that, why write another one?

Most impl-switcher plugins in the wild tend to, in my experience, require either a lot of configuration, a lot of dependencies, or a very specific project layout (or a combination of all three). They also seem to be huge and very complicated projects.

Impl switcher will recursively go up your directory hierarchy and use “find” to locate any files named like your base file but with a different extension. That makes it very simple and it requires minimal (if any) configuration: just drop it in your .vimrc file and you’re good to go. OK, not exactly: it requires a Linux-like system with utilities like “find”. Still, a good trade-off to keep the project’s dependencies as small as possible.

Get “impl swicher” here:

 


Vim utilities: Better Tab New

I spent some time writing utility scripts for my Vim setup. I figured I can share them here, someone may even find them useful or at least get a laugh out of it. The first one is called “Better Tab New” and you can get it from my Gihub repo or from the script’s Vim page.

Why would you want a better tab new, and what’s wrong with the default one? Simple: tabnew, in Vim, will just open a file. For that to happen you need to specify the exact path of a file. That’s usually perfectly fine, but sometimes you need tabnew to be a bit smarter: maybe you just grep’ed something and ended up with a path that looks like “/foo/bar/baz:my_text:42”. Or maybe you want to open a file and go to a specific line. Those are things for which the default tabnew implementation isn’t very good. BTN fills that niche and lets you create a simpler workflow when using grep.

Get BTN: Better Tab New here: