6 votes
Accepted

Project Wide replace using Ag

You don't need a plugin for using The Silver Searcher — or any other grep alternative — in Vim: set grepprg=ag\ --nogroup\ --nocolor\ --ignore-case\ --column\ --vimgrep set grepformat=%f:%l:%c:%m,%f:%...
  • 33.3k
6 votes
Accepted

my ag shortcut chokes on spaces

Why It's Broken The problem is that you've used -bar in your command definition. This attribute is used to specify that you can use a | after an invocation of your new command e.g.: :Ag search_term | ...
  • 29k
5 votes
Accepted

How to call the fzf Ag command with multiple arguments?

TL;DR: You can't pass ag options into that command. (But jump to the bottom for a different one.) Note the distinction between the :Ag command and the fzf#vim#ag function. The :Ag command calls the ...
  • 29k
4 votes
Accepted

How to see the number of search return with Ag?

:Ag inserts its results into a so-called Quickfix window and, as for anything loaded there, an indication of the current result and total results will be displayed on the right side of the status line....
  • 18.5k
4 votes
Accepted

Don't expand `%` in external grep call

In the Vim command line, the % is a special placeholder for the current buffer name. See :help cmdline-special. To avoid the expansion, just escape the character with a backslash: :grep -Q '{\% amount'...
3 votes

Project Wide replace using Ag

It looks like you have to :AgAdd instead of just Ag, which will add the results to quick links.
  • 1,063
3 votes

Project Wide replace using Ag

Use macros to do what you want. Start at the first replacement, :cr, then... (Comments just for description.) qbq " clear b register qa " start recording macro a :s/old text/new text/ :cn q " end ...
3 votes
Accepted

why doesn't ag in my vimrc ignore multiple patterns

You haven't escaped your command correctly: set grepprg=ag\ --nogroup\ --nocolor\ --ignore\ wiki --ignore\tests ^ ^ There is a missing ...
  • 29k
3 votes

How to setup AG (the silver searcher) in vim?

I use silver searcher too and actually I ended up with this binding: nnoremap K :silent grep! "\b\s?<C-R><C-W>\b"<CR>:cw<CR>:redr!<CR> See at :redr! command at the end ...
3 votes
Accepted

Accept hyphen when using `<C-R><C-W>`

A straightforward (if not exactly elegant) way to do this is just to temporarily set iskeyword to include the hyphen: nnoremap <silent> K :let s:old_iskeyword = &l:iskeyword<CR> \:...
  • 29k
3 votes
Accepted

How to keep Ag (the silver searcher) open when no matches are found?

This is because you are using :cwindow to open the window. See :help :cwindow: Open the quickfix window when there are recognized errors. If the window is already open and there are ...
  • 29k
3 votes
Accepted

Any way to prevent :Ag search from automatically opening the first returned result?

I don't have the plugin but if I'm reading the docs correctly you just need to add bang !... :Ag[!] [options] {pattern} [{directory}] *:Ag* Search recursively in ...
  • 18.5k
1 vote
Accepted

How to add a fallback when :b buffer change fails

You can't change the way the :b command works, but you can create an alternative :B command, and then create an abbreviation to always use the :B command when you type :b. The below works by first ...
  • 29k
1 vote
Accepted

how to go back and forth in the view stack in vi

Jumplist You can use <c-o> / <c-i> to travel back and forward through the jump list. You can see the jump list via :jumps. However this my not be the fastest way to get back as you may ...
1 vote

how to go back and forth in the view stack in vi

You can use :bpre and :bnext to go to previous buffer and next one.
  • 1,136
1 vote

How to dismiss the bottom search bar

It's called the quickfix window. (See :h quickfix) It can be dismissed with the command :cclose or with any regular window command. e.g. Ctrl-Wc or Ctrl-Wo. One way you could do this: nnoremap <...
  • 29k
1 vote

Project Wide replace using Ag

But why you want to do this via Vim? It would be much easier to run ag -l pattern | xargs -n1 sed 's/pattern/replacement/g in Your shell (or at least via :!).
  • 217
1 vote

Search for %, $ using :Ag

Did you try the following? :Ag \\$
  • 33.3k

Only top scored, non community-wiki answers of a minimum length are eligible