All Projects β†’ vrothberg β†’ Vgrep

vrothberg / Vgrep

Licence: gpl-3.0
vgrep - a user-friendly pager for grep

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Vgrep

Ugrep
πŸ”NEW ugrep v3.1: ultra fast grep with interactive query UI and fuzzy search: search file systems, source code, text, binary files, archives (cpio/tar/pax/zip), compressed files (gz/Z/bz2/lzma/xz/lz4), documents and more. A faster, user-friendly and compatible grep replacement.
Stars: ✭ 626 (+27.24%)
Mutual labels:  source-code, grep
Curriculum
Dive into our 7-month web development program covering HTML, CSS, Javascript, Node, and React!
Stars: ✭ 453 (-7.93%)
Mutual labels:  frontend
Bsed
Simple SQL-like syntax on top of Perl text processing.
Stars: ✭ 414 (-15.85%)
Mutual labels:  grep
Reagent
The idea and some of the code for making components atom-like comes from pump. The reactive-atom idea (and some code) comes from reflex.
Stars: ✭ 4,344 (+782.93%)
Mutual labels:  frontend
Client
The Hypothesis web-based annotation client.
Stars: ✭ 416 (-15.45%)
Mutual labels:  frontend
Xi Term
A terminal frontend for Xi
Stars: ✭ 446 (-9.35%)
Mutual labels:  frontend
Vue Skeleton Mvp
VueJs, Vuetify, Vue Router and Vuex skeleton MVP written on JavaScript using async/await built to work with API REST skeleton: https://github.com/davellanedam/node-express-mongodb-jwt-rest-api-skeleton
Stars: ✭ 406 (-17.48%)
Mutual labels:  frontend
Reactive Interaction Gateway
Create low-latency, interactive user experiences for stateless microservices.
Stars: ✭ 465 (-5.49%)
Mutual labels:  frontend
Codespan
Beautiful diagnostic reporting for text-based programming languages.
Stars: ✭ 445 (-9.55%)
Mutual labels:  source-code
Imba
🐀 The friendly full-stack language
Stars: ✭ 5,434 (+1004.47%)
Mutual labels:  frontend
Mobx Angular
MobX connector to Angular
Stars: ✭ 432 (-12.2%)
Mutual labels:  frontend
Annotated Webpack Config
This is the companion github repo for the "An Annotated webpack 4 Config for Frontend Web Development" article.
Stars: ✭ 425 (-13.62%)
Mutual labels:  frontend
Framework
A modular front-end framework - inspired by the server-side and Web Components.
Stars: ✭ 448 (-8.94%)
Mutual labels:  frontend
React Blur
React component to blur image backgrounds using canvas.
Stars: ✭ 416 (-15.45%)
Mutual labels:  frontend
Quelpa
Build and install your Emacs Lisp packages on-the-fly directly from source
Stars: ✭ 455 (-7.52%)
Mutual labels:  source-code
Blush
Grep with colours
Stars: ✭ 410 (-16.67%)
Mutual labels:  grep
Swiftuipager
Native Pager in SwiftUI
Stars: ✭ 430 (-12.6%)
Mutual labels:  pager
Ivi
πŸ”₯ Javascript (TypeScript) library for building web user interfaces
Stars: ✭ 445 (-9.55%)
Mutual labels:  frontend
San
A fast, portable, flexible JavaScript component framework
Stars: ✭ 4,514 (+817.48%)
Mutual labels:  frontend
Viewpager Transformation
Why use dependencies when you create your own transformations for Viewpager ?
Stars: ✭ 463 (-5.89%)
Mutual labels:  source-code

vgrep logo

Build Status

vgrep is a pager for grep, git-grep, ripgrep and similar grep implementations, and allows for opening the indexed file locations in a user-specified editor such as vim or emacs. vgrep is inspired by the ancient cgvg scripts but extended to perform further operations such as listing statistics of files and directory trees or showing the context lines before and after the matches. vgrep runs on Linux, Windows and Mac OS.

Please, feel free to copy, improve, distribute and share. Feedback and patches are always welcome!

Install Instructions

Searching Patterns

The basic functionality of vgrep is to perform textual searches. On a technical level, vgrep serves as a front-end to grep or git-grep when invoking vgrep inside a git tree and uses less for displaying the results. All non-vgrep flags and arguments will be passed down to grep. Results of the last search are cached, so running vgrep without a new query will load previous results and operate on them.

An example call may look as follows:

By default, the output will be written to less to make browsing large amounts of data more comfortable. vgrep --no-less will write to stdout.

Opening Matches

vgrep can open the indexed file locations in an editor specified by the EDITOR environment variable. Opening one of the file locations from the previous example may look as follows:

# export EDITOR=gedit
# vgrep --show 4

The default editor of vgrep is vim with the default flag to open a file at a specific line being + followed by the line number. If your editor of choice hits the rare case of a different syntax, use the EDITORLINEFLAG environment variable to adjust. For example, a kate user may set the environment to EDITOR="kate" and EDITORLINEFLAG="-l".

Note that vgrep does not allow for searching and opening files at the same time. For instance, vgrep --show=files text should be split in two commands: vgrep text and vgrep --show=files.

IDE Support

Note that if you run vgrep inside a terminal of VSCode or Goland, the format of listed files changes to "$PATH:$LINE" to allow for opening the matches in the editor via a simple mouse click.

More Commands and the Interactive Shell

Once vgreped, you can perform certain operations on the results such as limiting the range of indexed matches, listing matching files and directories and more.

Enter a vgrep command: ?
vgrep command help: command[context lines] [selectors]
         selectors: '3' (single), '1,2,6' (multi), '1-8' (range), 'all'
          commands: print, show, context, tree, delete, keep, refine, files, grep, quit, ?

vgrep commands can be passed directly to the --show/-s flag, for instance as --show c5 1-10 to show the five context lines of the first ten matched lines. Furthermore, the commands can be executed in an interactive shell via the --interactive/-i flag. Running vgrep --interactive will enter the shell directly, vgrep --show 1 --interactive will first open the first matched line in the editor and enter the interactive shell after.

vgrep supports the following commands:

  • print to limit the range of matched lines to be printed. p 1-12,20 prints the first 12 lines and the 20th line.
  • show to open the selectors in an user-specified editor (requires selectors).
  • context to print the context lines before and after the matched lines. c10 3-9 prints 10 context lines of the matching lines 3 to 9. Unless specified, vgrep will print 5 context lines.
  • tree to print the number of matches for each directory in the tree.
  • delete to remove lines at selected indices from the results, for the duration of the interactive shell (requires selectors).
  • keep to keep only lines at selected indices from the results, for the duration of the interactive shell (requires selectors).
  • refine to keep only lines matching the provided regexp pattern from the results, for the duration of the interactive shell (requires a regexp string).
  • files will print the number of matches for each file in the tree.
  • grep start a new search without leaving the interactive shell (requires arguments for a vgrep search). For example, g -i "foo bar" dir/ will trigger a case-insensitive search for foo bar in the files under dir. The cache will be updated with the results from the new search.
  • quit to exit the interactive shell.
  • ? to show the help for vgrep commands.

vgrep command examples

Context lines

Tree

Files

fzf

If you desire a more interactive experience than running vgrep twice to first search and then to open an editor, you may have a look at fzf. The below function uses fzf to interactively search with vgrep and open your editor with one enter at the correct line. To use it add the following function to your .bashrc and install fzf alongside vgrep and ripgrep.

vgrep() {
  INITIAL_QUERY="$1"
  VGREP_PREFIX="vgrep --no-header "
  FZF_DEFAULT_COMMAND="$VGREP_PREFIX '$INITIAL_QUERY'" \
  fzf --bind "change:reload:$VGREP_PREFIX {q} || true" --ansi --phony --tac --query "$INITIAL_QUERY" \
  | awk '{print $1}' | xargs -I{} -o vgrep --show {}
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].