Find Code Snippets with Context and Click to Navigate Directly to Results

Search across R files with contextual results, highlights and clickable links. Includes an add-in for further workflow enhancement.


contextFind

CRAN_Status_Badge R CMDCheck

The goal of contextFind is to help developers find relevant parts of their code, especially helpful when code expands beyond a single file, such as with Shiny applications.

The package includes an addin to bind contextFind() to a hotkey (e.g., Ctrl+Shift+F). This opens a mini shiny application with inputs for the search string, the directory, whether to search subdiretories, and how many lines of context to print before and after the found search string:

Clicking the contextFind button prints the results to the console. For each result (match), contextFind() provides a clickable labelled link indicating the file and line number of the result, followed by contextLines=2 lines before and after the occurrence, with the found string highlighted in yellow. The results are ordered with most recently modified files at the bottom of the list for ease of reading in the console.

Installation

You can install the latest version of contextFind from GitHub with:

devtools::install_github("s87jackson/contextFind")

or the CRAN stable release with:

install.packages("contextFind")

Use

After installing contextFind, restart RStudio, then set contextFind to a hotkey by selecting Tools >> Modify Keyboard Shortcuts:

Now typing Ctrl+Shift+F opens the gadget to perform the search. If text is higlighted when you type the hotkey, it will be passed to the gadget automatically. In the example below, we search for the string ‘selected’ and see the results:

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("contextFind")

1.0.1 by Steve Jackson, a year ago


Browse source code at https://github.com/cran/contextFind


Authors: Steve Jackson [aut, cre] (ORCID:


Documentation:   PDF Manual  


CC0 license


Imports rstudioapi, cli, shiny, miniUI

Suggests testthat, knitr, rmarkdown


See at CRAN