Ack in terminal vim is flashing it's output before presenting search results. How to stop it?
Asked Answered
S

2

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?

Spermato answered 10/11, 2012 at 12:43 Comment(0)
M
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).

Matchmaker answered 10/11, 2012 at 13:13 Comment(3)
Setting shellpipe to &> worked. Look at github.com/mileszs/ack.vim/issues/18 to see how I integrated this fix into ack.vim. Thanks to ZyxSpermato
@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.Matchmaker
It might be useful to also do set shell=bash for these to work.Pane
M
0

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

Mogerly answered 13/6, 2014 at 13:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.