4 ms·
I don't see why being effective in vim means you ^z out of vim to run `ack` or `grep`, instead of pressing ^f (for example) to run Ack.vim on the <cword> and ha
by JackCh 8y ago
I don't see why being effective in vim means you ^z out of vim to run `ack` or `grep`, instead of pressing ^f (for example) to run Ack.vim on the <cword> and have the results displayed next to your code in a window that, when you select the item you want, opens that corresponding file in a buffer with your cursor already on the line in question. Certainly you don't need ack.vim, you could just ^z and do it the old fashioned way, but where is the utility in that?
As for the unix philosophy, it's all about programs doing one thing and doing it well... but isn't it also about composing those programs to do the job you need done? If you're just ^z'ing out of vim to run `grep` or `ack`, how do you get those results back into vim? copy/paste it through your terminal emulator, using tmux in the best case scenario? How is that more in line with the unix philosophy than simply having vim shell out to those utilities for you?
^z to run unix utilities is like coping the output of one command into a file on disk before sending it to another, instead of simply piping the output of one into the input of another using the functionality of your shell. If vim filling in for a shell violates the philosophy, then damn the philosophy. I'd rather have "the traditional shell+domain specific shells(vim, ranger, etc)" than turn the traditional shell into a one-size-fits-poorly shell.
https://github.com/mileszs/ack.vim https://github.com/mileszs/ack.vim (Because ack.vim and plugins like it are actually in keeping with the so-called unix philosophy for reasons I outlined above, you don't actually have to use `ack` with ack.vim. I use it with `ag` (the silver searcher) instead.)
- Sir_Cmpwn 8y ago>Certainly you don't need ack.vim, you could just ^z and do it the old fashioned way, but where is the utility in that? Because ack.vim can't be piped into other tools. You can't, for example, limit your search to the last 50 files modified. Or only to executable files. You can't pipe the results into sed or make matching files world-readable. Sure, you could install ack.vim, slow down vim's startup and bloat your installation, or you could just hit ^z and use the unparalleled power of the Unix shell. >How is that more in line with the unix philosophy than simply having vim shell out to those utilities for you? Sometimes it's not. But vim has ! built in, you don't need plugins to run commands from it. I do it all the time.
- JackCh 8y ago> "or you could just hit ^z and use the unparalleled power of the Unix shell." Or I could use both, when the need arises, which frankly it never has for me. Ack.vim does not preclude using ^z when you have a special need, it optimizes the common case. And Ack.vim is much nicer than !ack <cword> > "install ack.vim, slow down vim's startup and bloat your installation" Well I don't run vim on a z80, so the difference would be pretty hard to measure ;). The way modern well-coded vim plugins like Ack.vim work involves lazyloading using 'autoload' (which is poorly named.) Ack.vim includes plugin/ack.vim (p/av) and autoload/ack.vim (a/av). p/av loads when you start vim, but is a light-weight file that only contains keybindings and settings variables. The actual code of Ack.vim, the function definitions, exists in a/av which is loaded lazily, when one of those functions is called by a keybinding created in p/av. The result is a truly negligible startup impact. https://github.com/mileszs/ack.vim/blob/master/plugin/ack.vim https://github.com/mileszs/ack.vim/blob/master/plugin/ack.vi... https://github.com/mileszs/ack.vim/blob/master/autoload/ack.vim https://github.com/mileszs/ack.vim/blob/master/autoload/ack....
- joshuamorton 8y ago"simple things should be easy, hard things should be possible." I rarely (if ever) need to make matches world readable from the context of text editing. When I do, there's nothing stopping me from using ^z, but until that day comes, a plug-in is going to be fewer keystrokes, faster, and better integrated with what I was already doing.
- pasabagi 8y agoOne thing I don't understand, is how do you handle mistakes with the 'unix-as-ide' approach? I was using sed to refactor. Now, I typically use bufdo %s/foo/bar/gc, because it's much more forgiving. It's the same story with a lot of stuff you can ctrl-z for - if you can do it inside vim, it's usually far easier to control and roll back.
- C0d3r 8y agoGit helps you with those mistakes, otherwise, yes, very unforgiving
- danidiaz 8y agoStrictly speaking, one doesn't even need a plugin to use ack, ag or ripgrep from Vim. It is enough to set the "grepprg" option (perhaps also "grepformat") and then one can invoke the built-in ":grep" command. For example, to use ripgrep: set grepprg=rg\ --vimgrep\ --no-heading
- JackCh 8y ago:grep is what I used originally and found it unsatisfactory; eventually I switched to my own keybinding for !ack <cword>, then some time after that switched to Ack.vim with ag.
- burntsushi 8y agoSmall note: --vimgrep implies --no-heading, so you can drop --no-heading. :-)