Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.
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:%...
user avatar
  • 32.6k
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 | ...
user avatar
  • 27.4k
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 ...
user avatar
  • 27.4k
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....
user avatar
  • 18.1k
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'...
user avatar
  • 16.6k
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.
user avatar
  • 1,053
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 ...
user avatar
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 ...
user avatar
  • 27.4k
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 ...
user avatar
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 ...
user avatar
  • 27.4k
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 ...
user avatar
  • 18.1k
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 ...
user avatar
  • 27.4k
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 ...
user avatar
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.
user avatar
  • 1,046
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 <...
user avatar
  • 27.4k
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 :!).
user avatar
  • 217
1 vote

Search for %, $ using :Ag

Did you try the following? :Ag \\$
user avatar
  • 32.6k

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