←back to thread

538 points todsacerdoti | 1 comments | | HN request time: 0.208s | source
Show context
robenkleene ◴[] No.44358285[source]
I love this, I've been iterating on workflows like this for something like a decade now. Over time I've tried to peel back as many of my custom layers as possible, because all of those layers have a maintenance cost.

Stock Vim (without `tmux`) can actually do most of what's shared in this post with `rg --vimgrep restore_tool | vim -c cb -` (`vim -c cb -` is my favorite feature in Vim; I find it strange that it's so rarely used or talked about).

(Since re-running the `rg` search can be undesirable, and I often like to analyze results in a terminal before opening them in Vim. I use a custom `tmux` command to copy the output of the last command [using this trick that involves adding a Unicode character to your prompt https://ianthehenry.com/posts/tmux-copy-last-command/], then I send that into Vim with e.g., `tmux saveb - | vim -c cb -`.)

replies(7): >>44358653 #>>44358736 #>>44360925 #>>44362611 #>>44363893 #>>44364510 #>>44403351 #
lynx97 ◴[] No.44363893[source]
"rg --vimgrep restore_tool | vim -c cb -" looks like I want to use it. However, it doesn't work for me. vim says it had errors while processing, and says I haven't saved the buffer. I get the rg result displayed, but how do I navigate to a place?
replies(1): >>44363967 #
covoeus ◴[] No.44363967[source]
Use `cb!` instead of `cb`:

    rg --vimgrep restore_tool | vim -c cb! -
You might also wanna open the quickfix list by default:

    rg --vimgrep restore_tool | vim -c cb! -c copen -
You can learn more about how to navigate it using `:h quickfix`.
replies(3): >>44364087 #>>44366369 #>>44375122 #
1. _sharp ◴[] No.44366369[source]
This is amazing! Thank you!!

The quickfix window is so small, so I added the "-c only" option to make it the only window that first pops up. Then made it a function so it's easier to call:

``` vgrep() { rg --vimgrep "$1" | vim -c cb! -c copen -c only - } ```

$> vgrep "restore_tool"