1

Is there a way to exclude files from an ag search by adding an array of files to the vimrc file?

Like with FuzzyFinder, file extensions are ignored by adding this:

let g:fuf_file_exclude = '\v\~$|\.o$|\.exe$|\.bak$|\.swp$|\.class$'

I actually just want to exclude my style.css as most of the time I want to locate a term in the scss working file and not the minified output in style.css.

Chad Nouis
  • 6,861
  • 1
  • 27
  • 28
Daniel Florido
  • 79
  • 2
  • 12

1 Answers1

4

ag will read in most VCS ignore files by default (see the --skip-vcs-ignores option -- you have to turn it off specifically). This means it will read .gitignore file (or .hgignore, or svn:ignore) in your project and ignore anything in there. Works well for my needs.

If you are having problems with compiled CSS files (or source maps, or the like) you might also want to configure your build scripts or whatever you use (grunt, gulp) to keep the .scss files in a /src directory and the .css files in /public (for instance) - and then add "public/" to .gitignore.

sbeam
  • 4,622
  • 6
  • 33
  • 43
  • what location does ag look for the .gitignore/hgignore file? – Daniel Florido May 26 '16 at 04:01
  • it's usually kept in your project root (for project-specific ignore rules) or can be in your home directory (if you want ignore rules applied to all your projects). I believe ag will find it in either place, or in any directory that's higher than the current working directory. – sbeam May 26 '16 at 04:06
  • Sorry to keep on morphing this into something else. how does ag know what the project root is? do i need to set it with https://github.com/vim-scripts/project.vim ? – Daniel Florido May 26 '16 at 04:32
  • no, it doesn't even need to know. Your vim has a current directory (`:pwd`) which you can change with `:cd`. I believe ag will look in that directory and all ancestor directories for a `.gitignore` file. But if you use git, then there would probably be a `.gitignore` file in the project root directory anyway (where the `.git/` directory is) – sbeam May 26 '16 at 05:00