12

I'm using vim inside gnome-terminal in Ubuntu 12.04 and also in MacOS's terminal. I use the ack.vim plugin to perform project wide textual searches and it works fine but there's an uncomfortable and distracting bug:

When you perform a search, the whole vim screen goes back to the terminal and shows ack's output as it runs. When it stops running, the screen goes back to vim and the search results are correctly shown. Also, when you quit vim, all of ack's output will be there in the terminal.

I'm aware of this issue https://github.com/mileszs/ack.vim/issues/18 but I wanted to post it here to see if I can get ideas on how to fix it.

In ack.vim I can see the line silent execute a:cmd . " " . l:grepargs which I think is where the ack command is actually being run. The silent option is already there, that's as far as my vim-fu takes me. :S

Anyone has any ideas on how to fix this?

Rafael Vega
  • 4,575
  • 4
  • 32
  • 50

2 Answers2

8

This is a problem of how vim own :grep* commands work, not something that is ack.vim issue. You can’t prevent using the terminal, but setting shellpipe to >, &> or 2>/dev/null> will prevent command from duplicating the output to the terminal (by default this option is 2>&1|tee and &> or 2>&1> values are the closest to what is currently done).

ZyX
  • 52,536
  • 7
  • 114
  • 135
  • Setting shellpipe to &> worked. Look at https://github.com/mileszs/ack.vim/issues/18 to see how I integrated this fix into ack.vim. Thanks to Zyx – Rafael Vega Nov 10 '12 at 13:55
  • 3
    @RafaelVega It was supposed to be set in your vimrc. **Don’t suggest to set it in plugin.** AFAIR this is wrong for `csh` on linux, definitely wrong for `cmd.exe` on windows. – ZyX Nov 10 '12 at 14:41
  • It might be useful to also do `set shell=bash` for these to work. – gauteh Aug 17 '18 at 09:28
0

The suggested solution works, but now the vim-screen is in the output after pressing ctrl-z.

mollerhoj
  • 1,298
  • 1
  • 10
  • 18