# How to Configure ripgrep to Search Hidden Files and Directories

> Learn how to configure ripgrep to search hidden files and directories using the powerful --hidden flag. Discover ripgrep's default behavior and override it with this simple solution.

- Repository: [Andrew Gallant/ripgrep](https://github.com/BurntSushi/ripgrep)
- Tags: how-to-guide
- Published: 2026-03-05

---

**Use the `--hidden` flag (or `-.` for short) to force ripgrep to search files and directories whose names begin with a dot, overriding the default behavior that ignores hidden paths.**

By default, ripgrep excludes hidden files and directories—those prefixed with a dot like `.git` or `.config`—from search results to keep output clean and relevant. If you need to configure ripgrep to search hidden files and directories, you must explicitly enable the **hidden** flag to include these paths in the recursive walk. This article explains the exact command-line options and their implementation in the BurntSushi/ripgrep source code.

## Understanding ripgrep's Default Hidden File Behavior

ripgrep automatically filters out entries whose basenames start with a period (`.`) as well as files marked with the platform-specific hidden attribute on Windows. This filtering occurs at the walker level before pattern matching begins, ensuring that system directories and version control metadata remain out of your results unless specifically requested.

According to the implementation in [`crates/core/flags/defs.rs`](https://github.com/BurntSushi/ripgrep/blob/main/crates/core/flags/defs.rs) (lines 2772-2804), the walker iterator discards these entries by default to optimize performance and reduce noise in typical project searches.

## Enabling Hidden File Search

### Using the --hidden Flag

To include hidden files and directories, pass the `--hidden` option. This flag instructs the underlying directory iterator not to discard entries beginning with a dot or bearing the hidden attribute on Windows.

```bash
rg --hidden "TODO"

```

### Using the Short Form (-.)

For faster typing, use the `-.` shorthand, which is equivalent to `--hidden`. This short form is defined alongside the long form in [`crates/core/flags/defs.rs`](https://github.com/BurntSushi/ripgrep/blob/main/crates/core/flags/defs.rs) and provides identical functionality.

```bash
rg -. "SECRET_KEY"

```

### Combining with the -uu Shortcut

When you need to search hidden files while also bypassing `.gitignore`, `.ignore`, and other ignore files, use the `-uu` compound flag. As documented in `crates/core/flags/doc/template.rg.1` (lines 34-50), this expands to `--no-ignore --hidden`, effectively searching every file in the directory tree regardless of ignore rules.

```bash
rg -uu "password"

```

This is particularly useful when auditing configuration files or searching across entire home directories where ignore files might otherwise exclude hidden paths.

## Practical Command Examples

Search for patterns inside hidden configuration directories while showing line numbers:

```bash
rg --hidden -n "fn main" ~/.config

```

Combine hidden file search with context lines to see surrounding code:

```bash
rg -. -C 2 "API_KEY"

```

Perform a completely unrestricted search that includes hidden files, binary files, and ignores all filters:

```bash
rg -uu -a "FIXME"

```

Search for the word "TODO" across all files including hidden ones but respecting gitignore rules:

```bash
rg --hidden TODO

```

## Implementation Details

The hidden flag logic resides in [`crates/core/flags/defs.rs`](https://github.com/BurntSushi/ripgrep/blob/main/crates/core/flags/defs.rs), where the walker configuration is modified to respect the user's choice to include dotfiles. The feature is also documented in [`GUIDE.md`](https://github.com/BurntSushi/ripgrep/blob/main/GUIDE.md) (lines 190-199) as part of ripgrep's primary filtering toggles, illustrating how the tool balances performance with configurability. The Windows-specific hidden attribute check ensures consistent cross-platform behavior when the flag is enabled.

## Summary

- ripgrep ignores hidden files by default to exclude system and configuration directories from results.
- Use `--hidden` or `-.` to enable searching files and directories starting with a dot.
- The `-uu` shortcut combines `--hidden` with `--no-ignore` for completely unrestricted searches.
- These flags are implemented in [`crates/core/flags/defs.rs`](https://github.com/BurntSushi/ripgrep/blob/main/crates/core/flags/defs.rs) and documented in both the man page template and user guide.

## Frequently Asked Questions

### Does ripgrep search hidden files by default?

No. ripgrep automatically excludes files and directories whose names begin with a dot (`.`) as well as Windows hidden files unless you explicitly pass the `--hidden` or `-.` flag.

### What is the difference between --hidden and -uu in ripgrep?

The `--hidden` flag only includes dotfiles while still respecting `.gitignore` rules, whereas `-uu` (equivalent to `--no-ignore --hidden`) searches hidden files and completely ignores all ignore-file rules.

### Can I configure ripgrep to always search hidden files?

Yes. You can set the `RIPGREP_CONFIG_PATH` environment variable to point to a configuration file containing `--hidden`, or create a shell alias like `alias rg='rg --hidden'` to make the behavior persistent across sessions.

### Why does ripgrep skip hidden directories like .git?

ripgrep skips these by default to avoid noise from version control metadata and system configuration files, keeping search results focused on project source code unless you explicitly configure it to search hidden files and directories.