# Searching


# On the page

`/` searches as you type and highlights every match; `Enter` keeps it, `n` and `N` go to the next and previous match, and `*` searches the word under the cursor. The search ignores case unless you type a capital.


# In the whole book

`Ctrl-p` (or `Space /`) searches every chapter and goes to the exact line. The book's pages load in the background as soon as tomes starts, so the search covers the whole book after a moment.


tomes


``` term-output
tomes https://r4ds.hadley.nz/
```


tomes


``` term-screen
 R for Data Science (2e)         │                                                                           ┃
▸Welcome                         │ R for Data Science (2e)                                                   ┃
 Preface to the second edition   │ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━  ┃
 Introduction                    │                                                                           ┃
 Whole game                      │ Welcome                                                                   ┃
 1  Data visualization           │ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━  ┃
 2  Workflow: basics             │                                                                           ┃
 3  Data transformation          │                ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▀▀▄▄▄▄▄▄▀▄▄▄                  ┃
 4  Workflow: code style         │                  ▀▀▀▀▀▀▀▀▀                  ▄▄▀▀▀▀▄▀▀▄▀▀                  ┃
 5  Data tidying                 │                  ▄▄▄▄▄▄▄▄▄                    ▄▄▀▄▄▀▄▀▀▄                  ┃
 6  Workflow: scripts and proj…  │                  ▀▀▀▀▀ ▀▀▀      ▀▀▀▀▀▀   ▀▀▀    ▄▄▀▄▄▄▄                   │
 7  Data import                  │                   ▀▀▀▄ ▄▄▀▀▄▀▀▀▄ ▄▄▄▄▀▀▄▀▀▄▀▀▄▀▀  ▄▄▀▀                    │
 8  Workflow: getting help       │                  ▄▄▄▄▀ ▄▄▄▀▀▄▄▄ ▄▄▀▀▄▄▀▀▀▄▄▀▄▀▀▄    ▄▄▀▀                  │
 Visualize                       │                  ▀▀▀▀  ▄▀▀▄▄▄▄▄  ▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄      ▄▄                  │
 9  Layers                       │                  ▄▄▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▄▀▀▀▀▀                                 │
 10  Exploratory data analysis   │                  ▀▀▀▄▄▀▀▀▄▄▄▀▄▄▄▄▄▀▀▀▄▀▄▄                                 │
 11  Communication               │                  ▀▀▄▀▀▀▄▀▀▀▄▀▀▀▀▀▀▀▄▀▀▄▀▀▀▀                               │
 Transform                       │                  ▄▄▄▄▄▀▀▀▄▄▀▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▀                              │
 12  Logical vectors             │                  ▄▄▄▄▄▄▄▄▄▄▄▄▄  ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀                         │
 13  Numbers                     │                              ▀▀▀▀▀▄▄▀▀▄▄▄▄▄▀▄▀▀▀▀▀                        │
 14  Strings                     │                            ▀▀▀▄▄▄▄▄▄▄▄▄▄▄▀▄▄▄▀▀▀▄▀▀                       │
 15  Regular expressions         │                           ▀▀▀▄▄▀▀▄▄▄▄▀▄▀▄▀▄▄▄▄▄▄▀▄▄                       │
 16  Factors                     │                         ▀▀▀▄▄▄▄▀▄▀▄▄▄▄▄▄▀▀▀▄▄▄▄▄▄▄▄                       │
 17  Dates and times             │                        ▀▀▀▀▀▀▀▀▀▀▄▄▄▀▀▀▄▄▀▄▄▄ ▄▄▄                         │
 18  Missing values              │                       ▀▀▀▀▀▀▀▀▄▄▀▄▄▄▄▄▀▄▄▄▄                               │
 19  Joins                       │                       ▄▄▀▄▀▄▄▄▄▀▀▄▀▀▄▄▄▄▄   ▀▀▀                           │
 Import                          │                       ▀▀▀▀▄▄▄▄▄▄▄▄▄▀▀▀▀▀▀ ▀▀▀▄▄                           │
 20  Spreadsheets                │                      ▀▀▀▀▄▄▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▄                           │
 21  Databases                   │                ▀▀▀▀▀▀▀▀▀▀▀▀▀▄▄▄▀▄▄▄▀▀▀▀▀▀▀▄▄▄▄▄                           │
 Welcome! Press ? for the keys, Space e for the outline, Ctrl-p to search         ▶ terminal  term  1/38  Top 
```


tomes


``` term-screen
 R for Data Science (2e)         │                                                                           ┃
▸W╭ Search the book (#headings $commands @tools !figures ^footnotes) ──────────────────────────────────────╮ ┃
 P│ › left join▏                                                                                35 results │ ┃
 I│────────────────────────────────────────────────────────────────────────────────────────────────────────│ ┃
 W│ $ #> LEFT JOIN planes                                                                                  │ ┃
 1│   21  Databases › 21.5.8 Joins                                                                         │ ┃
 2│ ! Figure 19.5: A visual representation of the left join where every row in x appears in the output.    │ ┃
 3│   19  Joins › 19.4 How do joins work?                                                                  │ ┃
 4│ ! …the previous diagram showing an left join, the x table now gains a virtual row so that every row i… │ ┃
 5│   19  Joins › 19.4 How do joins work?                                                                  │ ┃
 6│ ¶ • A left join keeps all observations in x, Figure 19.5. Every row of x is preserved in the output b… │ │
 7│   19  Joins › 19.4 How do joins work?                                                                  │ │
 8│ ¶ …in() have the same interface as left_join(). The difference is which rows they keep: left join kee… │ │
 V│   19  Joins › 19.3.2 Specifying join keys                                                              │ │
 9│ $ left_join(airlines)                                                                                  │ │
 1│   19  Joins › 19.3.1 Mutating joins                                                                    │ │
 1│ $ left_join(planes)                                                                                    │ │
 T│   19  Joins › 19.3.2 Specifying join keys                                                              │ │
 1│ $ left_join(planes, join_by(tailnum))                                                                  │ │
 1│   19  Joins › 19.3.2 Specifying join keys                                                              │ │
 1│ $ left_join(weather |> select(origin, time_hour, temp, wind_speed))                                    │ │
 1│   19  Joins › 19.3.1 Mutating joins                                                                    │ │
 1│ $ left_join(planes |> select(tailnum, type, engines, seats))                                           │ │
 1│   19  Joins › 19.3.1 Mutating joins                                                                    │ │
 1│ $ left_join(planes |> select(tailnum, type, engines, seats))                                           │ │
 1│   19  Joins › 19.3.1 Mutating joins                                                                    │ │
 I╰────────────────────────────────────────────────────────────────────── ↑↓ choose · Enter go · Esc close ╯ │
 20  Spreadsheets                │                      ▀▀▀▀▄▄▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▄                           │
 21  Databases                   │                ▀▀▀▀▀▀▀▀▀▀▀▀▀▄▄▄▀▄▄▄▀▀▀▀▀▀▀▄▄▄▄▄                           │
 Welcome                                                                          ▶ terminal  term  1/38  Top 
```


Headings, commands, and figure captions come first. `↑` and `↓` choose, `Enter` goes there, and the words you searched for stay highlighted, so `n` continues on the page.

Start with a character to search one kind of thing:

| Start with | Searches                                                   |
|------------|------------------------------------------------------------|
| `#`        | Headings                                                   |
| `$`        | Commands and code                                          |
| `!`        | Figure captions                                            |
| `^`        | Footnotes                                                  |
| `@`        | Command-line tools (in *Data Science at the Command Line*) |

`Space Space` lists the chapters to pick one.


# On the command line

``` bash
tomes -b https://r4ds.hadley.nz/ search "left join" -n 5
```

In a pipe, the matches are tab-separated: page, section, text.
