Title: Find Code Snippets with Context and Click to Navigate Directly to Results
Version: 1.0.1
Description: Search across R files with contextual results, highlights and clickable links. Includes an add-in for further workflow enhancement.
License: CC0
Encoding: UTF-8
RoxygenNote: 7.3.2
Imports: rstudioapi, cli, shiny, miniUI
Suggests: testthat (≥ 3.0.0), knitr, rmarkdown
Config/testthat/edition: 3
VignetteBuilder: knitr
NeedsCompilation: no
Packaged: 2025-10-22 19:20:42 UTC; SteveJackson
Author: Steve Jackson ORCID iD [aut, cre]
Maintainer: Steve Jackson <s87jackson@gmail.com>
Repository: CRAN
Date/Publication: 2025-10-26 20:30:08 UTC

Search R and Rmd Files for Matching Text, Get Context and Links

Description

Search R and Rmd Files for Matching Text, Get Context and Links

Usage

contextFind(
  search_text,
  path = ".",
  recursive = TRUE,
  contextLines = 2,
  verbose = TRUE
)

Arguments

search_text

Text to search for

path

Root directory to search

recursive

Whether to recurse into subfolders

contextLines

Number of context lines around match

verbose

If TRUE (the default), prints the results to the console

Value

A list of lists, one for each match, with objects: file, match_line, mtime, and context. file is the file path in which the match was found, match_line is the line number for this particular match, mtime is a POSIXct datetime value indicating when the file was last modified, and context contains the number of lines before and after the found match (set by the contextLines parameter).

Examples


# Find custom functions in your codebase
contextFind("<- function")

# Get more context
contextFind("<- function", contextLines = 3)

# Explicitly set the search directory
contextFind("<- function", path = getwd())

# Exclude subdirectories
contextFind("<- function", recursive = FALSE)


RStudio Add-in for contextFind

Description

Launches an interactive gadget for searching project files. The gadget allows the user to enter a search string, choose a directory, specify whether the search should be recursive, and how many lines of context to print. Results are displayed in the console with clickable links to matched lines.

Usage

contextFind_addin()

Value

Invisibly returns the search results as a list (see contextFind()).

See Also

contextFind()