惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

B
Blog
D
Docker
J
Java Code Geeks
腾讯CDC
Blog — PlanetScale
Blog — PlanetScale
G
Google Developers Blog
M
MIT News - Artificial intelligence
L
LangChain Blog
T
The Blog of Author Tim Ferriss
P
Proofpoint News Feed
MyScale Blog
MyScale Blog
博客园 - Franky
GbyAI
GbyAI
Hugging Face - Blog
Hugging Face - Blog
aimingoo的专栏
aimingoo的专栏
Last Week in AI
Last Week in AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 聂微东
N
Netflix TechBlog - Medium
B
Blog RSS Feed
Y
Y Combinator Blog
阮一峰的网络日志
阮一峰的网络日志
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google DeepMind News
Google DeepMind News

jdhao's digital space

Conversion between base64 and OpenCV or PIL Image 腾讯云对象存储博客图床开启 CDN 加速(不需要购买额外域名) Search and Replace in Multiple Files in Vim/Neovim Change Table Column Width in LaTeX Image or Table Side by Side in LaTeX LaTeX 并排显示图像或表格 Firenvim: Neovim inside Your Browser Content inside HTML tags missing in Latest Hugo? Creating Markdown Front Matter with Ultisnips Labelme JSON 标注格式转 voc XML 格式 Nifty Nvim Techniques That Make My Life Easier -- Series 6 macOS 下如何为视频制作字幕 Running Command Asynchronously inside Neovim Resolving Merge Conflict after Git Stash Pop Pylint: command not found? A Hands-on Experience with Neovim's Built-in LSP Support How to Convert PDF to Images with Imagemagick 互联网上常用缩略语集锦 File Backup in Neovim Converting PDF Pages to Images with Poppler Nifty Nvim Techniques That Make My Life Easier -- Series 5 Neovim Configuration for System-wide Use How to sort a list of tuple or list in Python -- lambda or itemgetter? Building A Vim Statusline from Scratch 人类第一颗原子弹爆炸始末 Distributed Training in PyTorch with Horovod Learning Expect Programming Essential Knowledge about SSH Nifty LaTeX Techniques -- Series 1 更改 Adsense 邮寄地址,重新寄送 PIN
Ripgrep Searching CheatSheet
2020-02-16 · via jdhao's digital space

Ripgrep is a command line tools that searches patterns under your current directory, like the good old grep, but with faster speed. In this post, I list some of the commonly-used flags for ripgrep.

commandDescription
rg image utils.pySearch in a single file utils.py
rg image src/Search in dir src/ recursively
rg imageSearch image in current dir recursively
rg '^We' test.txtRegex searching support (lines starting with We)
rg -i imageSearch image and ignore case (case-insensitive search)
rg -s imageSmart case search
rg -F '(test)'Search literally, i.e., without using regular expression
rg image -g '*.py'File globing (search in certain files), can be used multiple times
rg image -g '!*.py'Negative file globing (do not search in certain files)
rg image --type py or rg image -tpy1Search image in Python file
rg image -TpyDo not search image in Python file type
rg -l imageOnly show files containing image (Do not show the lines)
rg --files-without-match imageShow files not containing image
rg -v imageInverse search (search files not containing image)
rg -w imageSearch complete word
rg --countShow the number of matching lines in a file
rg --count-matchesShow the number of matchings in a file
rg neovim --statsShow the searching stat (how many matches, how many files searched etc.)

How to enable shell completion for ripgrep?#

The binary release of ripgrep also include completion files for Bash, Zsh. When we extract the binary release, the completion file is under completion/_rg. For zsh, we should move this file to one of the paths in env variable $fpath.

How to exclude directories#

To exclude directories, we also use the -g option. For example, to exclude dir1 and dir2, use the following command:

rg pattern -g '!dir1/' -g '!dir2/'
Changelog

update: 2020-12-03, add --stats option

References#