Skip to content

Commit

Permalink
New blog post.
Browse files Browse the repository at this point in the history
  • Loading branch information
gummesson committed Mar 28, 2016
1 parent db5f688 commit 595b8a6
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions _posts/2016-03-28-sift.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
title: "sift"
tags: ["Tools"]
layout: "post"
comments: true
link: false
---

Some time ago I came across [sift](https://sift-tool.org/), a "fast and powerful
open source alternative to [grep](https://www.gnu.org/software/grep/)".
[ack](http://beyondgrep.com/) has long been my weapon of choice, but it depends
on [Perl](https://www.perl.org/) while sift is distributed as a single
executable.

After using it as my daily driver for a couple of months I've noticed that it's
a worthy competitor to [git-grep](https://git-scm.com/docs/git-grep), although
the latter is still a bit faster.

## Configuration

sift has a feature, `--write-config`, which enables you to save your
configuration directly on the command line:

```
sift --smart-case --filename --line-number --group --column --git --exclude-files=tags,.gitattributes --write-config
```

The `--git` flag makes it possible to ignore patterns from a project's `.gitignore`
file, which is super nice.

## Fuzzy file finding

You can use the flag `--targets` to use sift as a fuzzy file finder:

```
sift --targets --ext js
```

You can also supply a pattern in order to narrow down the search:

```
sift --targets --ext js test
```

## Integrating with Vim

To use sift in [Vim](http://www.vim.org/), configure the `grepprg` and
`grepformat` options:

``` viml
set grepprg=sift\ --no-group\ --no-color
set grepformat=%f:%l:%c:%m,%f:%l:%m
```

Depending on how you've configured it you may need to add additional flags. In
order for the above `grepformat` to work you have to have `--filename`,
`--line-number` and `--column` enabled.

To use it as an indexer for [CtrlP](https://github.com/ctrlpvim/ctrlp.vim), add
this:

``` viml
let g:ctrlp_user_command = 'sift --no-conf --ignore-case --no-color --no-group --git --targets --path "" %s'
```

And you're good to go!

0 comments on commit 595b8a6

Please sign in to comment.