contextFind: Search R and Rmd Files for Matching Text, Get Context and...

View source: R/contextFind.R

contextFindR Documentation

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)


contextFind documentation built on Nov. 5, 2025, 6:04 p.m.