Comments (33)
@jonathankau This can hardly be considered “properly”. Correct variant is using 1. original &shellpipe
value and not anything hardcoded, 2. finally
and 3. shelleescape()
:
function Search(string) abort
let saved_shellpipe = &shellpipe
let &shellpipe = '>'
try
execute 'Ack!' shellescape(a:string, 1)
finally
let &shellpipe = saved_shellpipe
endtry
endfunction
. Note though that I may be incorrect regarding escaping here though: it is definitely correct variant for ag.vim
, but I am no longer using ack.vim
.
from ack.vim.
On my system (Linux, zsh) simple setting set shellpipe=>
in .vimrc
solved the problem.
from ack.vim.
Adding set shellpipe=>
does fix the issue, but it also blocks shell output from other plugins (like fugitive).
I ended up writing a Vimscript function that takes in the search param and makes sure to set/unset shellpipe properly:
function! Search(string)
set shellpipe=>
execute "Ack! \"" . a:string . "\""
set shellpipe=2>&1\|tee
endfunction
nnoremap <C-F> :call Search("")<left><left>
EDIT: Looks like @ZyX-I pointed out a couple issues with my implementation. I'm not very well-versed in Vimscript, so thanks for the help! 😄
from ack.vim.
I just installed the plugin and I notice I actually have this problem. Using vim on mac
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Feb 6 2017 06:58:22)
MacOS X (unix) version
Included patches: 1-311
Compiled by Homebrew
Can someone confirm this and maybe reopen the issue?
from ack.vim.
@skamsie Just added that set shellpipe=>
to my .vimrc and fixed it in the meantime.
from ack.vim.
Same here (on debian lenny) but no problem with MVim.
from ack.vim.
Happens to me also when running in a terminal. My entire screen flashes the output of Ack then back to Vim again. Rather distracting.
from ack.vim.
Happen to me on terminal vim, is there any fix for this?
from ack.vim.
+1 on this issue too. Only in vim not MacVim.
from ack.vim.
Just ran into this too; on iTerm2 with vim 7.3
from ack.vim.
+1 same problem here. Output is something like: [2] + 29217 suspended (tty output)
from ack.vim.
+1 same here. vim 7.3 in iTerm2.
from ack.vim.
+1, also on iTerm2 with Vim 7.3.
from ack.vim.
I'm experiencing the same issue, any idea what is causing that?
from ack.vim.
+1, also on iTerm2 with Vim 7.3.
from ack.vim.
+1 Same issue here.
OSX 10.7.5, iTerm2, Vim 7.3
from ack.vim.
I'm seeing it as well. I will look into it as soon as I can. If someone else has code that fixes it immediately, please note it here.
from ack.vim.
+1 I'm on Ubuntu 12.04, gnome terminal and vim 7.3
from ack.vim.
This fixed it for me. Thanks to ZyX in stack overflow: http://stackoverflow.com/questions/13322161/ack-in-terminal-vim-is-flashing-its-output-before-presenting-search-results-ho/13322352#13322352
let grepprg_bak=&grepprg
let grepformat_bak=&grepformat
let shellpipe_bak=&shellpipe
try
let &shellpipe="&>"
let &grepprg=g:ackprg
let &grepformat=g:ackformat
silent execute a:cmd . " " . escape(l:grepargs, '|')
finally
let &shellpipe=shellpipe_bak
let &grepprg=grepprg_bak
let &grepformat=grepformat_bak
endtry
Pull request: #52
from ack.vim.
@rvega It is bad idea to unconditionally use this fix: it is non-crossplatform, even on linux it may be wrong depending on value of the &shell
option.
from ack.vim.
We should definitely try to find a cross-platform solution.
from ack.vim.
ZyX-I, do you know in what instances specifically this will fail? What is the result of a failure? For instance, will one simply continue seeing the current odd behavior, or does it crash hard?
from ack.vim.
do you know in what instances specifically this will fail?
With cmd.exe
, tcsh
and dash
definitely. csh
should fail as well, but I have not tested.
What is the result of a failure?
cmd.exe
: unknown command (&
is the same as ;
in bash AFAIK).
dash
: ack is launched in the background and output is not get redirected appearing only in terminal (no support for stdout+stderr redirection with &>
, hence ampersand has its usual meaning: launch in background).
tcsh
: “invalid null command” error, nothing seems to be actually executed (different syntax).
For instance, will one simply continue seeing the current odd behavior, or does it crash hard?
It does not crash. Nor it does work, none of the variants result in target file being written to.
This is a thing that is supposed to be fixed in vimrc, if you are absolutely sure nobody needs viewing command output temporary before ack finishes you should switch to system()
, manual parsing of ack output and setqflist
/setloclist
. Writing to terminal is not a requirement for &shellpipe
(does not do so for cmd.exe
), just somebody thought it would be convenient for long-running commands (I guess). Setting it in the vimrc won’t break anything.
I definitely have no idea how such &shellpipe
overriding works in powershell, fish, ksh, ash, psh (is it useful as default shell in vim at all?) and a number of shells I don’t even know about. And I am absolutely sure if you want to fix this by overriding &shellpipe
then you end up with a big if..elsif..else..endif
block.
from ack.vim.
On Kubuntu 12.04 I see the flashing regardless of whether I'm using vim in the terminal or start gvim from krunner, and after flashing my top buffer has already been changed to show the top result.
from ack.vim.
In OSX 10.6 I've been having the same problems. In the terminal it will background vim while running the ack command. In MacVim it will just freeze until I quit (MacVim, not the command). Different terminals and shells make no difference.
from ack.vim.
Thanks for the advice @Kagami. However, it didn't work for me (on OSX 10.8.2 using zsh).
from ack.vim.
It's a default behaviour on vim use the same terminal session where vim was open to run system commands, with that when you closes vim the output of ran commands will be on terminal. To change this vim's default behaviour use: set t_ti= t_te=
from ack.vim.
In that case, does preserving the values &t_ti
and &t_te
just before called, then set t_ti= t_te=
, call ack, and restoring initial values (let &t_ti = saved_value_for_t_ti
) work as a fix?
This just occurred to me and I haven't dig into the possibility, so I'm sorry if I'm just showing stupidity.
from ack.vim.
This is still an issue for me.
@kassio suggests changing vim's default behavior, but this is no option for me.
@lesguillemets links to an issue which was solved with a commit that worked for me. Thanks!
from ack.vim.
@Kagami that worked for me- thanks!
from ack.vim.
Same issue for me with vim 8 on mac
from ack.vim.
I have this issue as well, output is printed on the screen and distracts a lot. set shellpipe=>
fixes this indeed. Is it the best way to solve this issue?
neovim, osx, iterm
from ack.vim.
@jonathankau Thank you! It works.
from ack.vim.
Related Issues (20)
- Empty result lines in Windows
- auto-preview leaves buffers open
- Progress Bar or Indicator
- Sort feature HOT 1
- Hotkey for refreshing search results
- Path for executable ag HOT 1
- Can not find the ag command HOT 3
- Error detected while processing function <SNR>213_QuickHelp:
- On pressing 'o' opens search result in a new tab.
- Keep initial search path
- Vim's default plugin management in README
- Neovim continues to show "Searching ..." in the command line even after search completes HOT 2
- Navigation configuration
- ag search results reported incorrectly in ack.vim's quickfix buffer, when source tree contains hard linked files
- T to open in new tab without moving to it moves cursor away from quickfix window
- run :Ack {pattern} and do not auto open any results HOT 2
- How can i set Ag to search only for word that inside files, not files names?
- Seeing `ag --vimgrep` output in my terminal after closing vim HOT 1
- Exact file not opening
- Vim with Ack and "Silver searcher" - can not open file from result panel
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ack.vim.