This plugin is a front for ag, A.K.A. the_silver_searcher, https://github.com/rking/ag.vim
Usage: ag [FILE-TYPE] [OPTIONS] PATTERN [PATH]
Ag searches from your current working directory if a PATH is not given.
- Check your working directory in Vim with
:pwd
- Change your working directory with
:cd [PATH]
(1) Find 0px
in any file except CSS.
:Ag --ignore *.css 0px
(2) How many 0px
matches were found in each file?
:Ag --count --ignore *.css 0px
(3) Now ignore CSS and LESS.
:Ag --ignore *.css --ignore *.less 0px
(4) Find /form/Form
only in HTML files.
:Ag -G html /form/Form
or Ag -G html \/form\/Form
- escaping
/
is optional -G
is an alias for--file-search-regex
; regex is allowed as the name implies
(5) Find lines ending in Miles
(use regex)
:Ag Miles$
Options are documented at https://github.com/ggreer/the_silver_searcher/blob/master/doc/ag.1.md
In the quickfix window, you can use:
e to open file and close the quickfix window
o to open (same as enter)
go to preview file (open but maintain focus on ag.vim results)
t to open in new tab
T to open in new tab silently
h to open in horizontal split
H to open in horizontal split silently
v to open in vertical split
gv to open in vertical split silently
q to close the quickfix window