• Stars
    star
    149
  • Rank 248,704 (Top 5 %)
  • Language
    Emacs Lisp
  • Created about 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Search and refactoring tool based on ripgrep.

What is color-rg?

color-rg is a search and refactoring tool based on ripgrep.

I'm a big fan of color-moccur.el, this extension's name is a tribute to color-moccur.el!

Installation

Clone or download this repository (path of the folder is the <path-to-color-rg> used below).

In your ~/.emacs, add the following two lines:

(add-to-list 'load-path "<path-to-color-rg>") ; add color-rg to your load-path
(require 'color-rg)

If you use Mac, you also need to install exec-path-from-shell

Usage

Bind your favorite key to functions:

Function Description
color-rg-search-input Search user's input with current directory
color-rg-search-symbol Search current symbol with current directory
color-rg-search-input-in-project Search user's input in project
color-rg-search-symbol-in-project Search current symbol in project
color-rg-search-symbol-in-current-file Search current symbol in current file
color-rg-search-input-in-current-file Search user's input in current file
color-rg-search-project-rails Search user's input in rails project
color-rg-search-symbol-with-type Search current symbol with current directory and special file extensions
color-rg-search-project-with-type Search user's input in project and special file extensions
color-rg-search-project-rails-with-type Search user's input in rails project and special file extensions

Keymap for view mode

Key Description
C-a Jump to first editable position of current line
Tab Jump to next match keyword
Back Tab Jump to previous match keyword
j Jump to next match keyword
k Jump to previous match keyword
h Jump to next match file
l Jump to previous match file
i Insert current line
SPC Open file
RET Open file relative to match line
Ctrl + m Open file relative to match line
r Replace all matches
e Enable edit mode
f Filter results match regexp
F Filter results not match regexp
x Filter results match file extension
X Filter results not match file extension
u Don't filter file extension
D Delete current line from results
I Toggle to include/exclude the ignore files then rerun last search
N Toggle to respect color-rg-search-ignore-rules then rerun last search
C Toggle to smart case/case sensitive then rerun last search
L Re-search pattern as literal
R Re-search pattern as regexp
G Rerun last search only include specified file type
E Rerun last search exclude specified file type
o Rerun last search in (up one level) parent directory
O Rerun last search in project root directory
s Rerun rg with customized directory.
S Rerun rg with customized arguments.
q Quit

Keymap for edit mode

Key Description
C-a Jump to first editable position of current line
C-c C-j Jump to next match keyword
C-c C-k Jump to previous match keyword
C-c C-h Jump to next match file
C-c C-l Jump to previous match file
C-c C-RET Open file relative to match line
C-c C-v Disable edit mode
C-c C-d Delete current line
C-c C-D Delete all lines
C-c C-r Recover current line
C-c C-R Recover buffer content
C-c C-q Quit
C-c C-c Apply changed line to files

Work with isearch

Add this into your emacs config file:

(define-key isearch-mode-map (kbd "M-s M-s") 'isearch-toggle-color-rg)

When using isearch-forward, type M-s M-s to search current isearch string with color-rg.

Research with new files

color-rg-rerun-change-files can limit search files with GLOB. This function used rg arguments '--type', '--add-type'.

Default search files is "everything" which means use rg without '--type' argument.

If search files is "all", search rg like "rg --type all".

Other complete candidates are mostly read from "rg --type-list" command, which is predefined in rg.

Of course you can specify your own GLOB, just insert them as you like. For example, if you input a GLOB like *mypersonalglob*, which match none of the candidates, then, color-rg will call shell command like:

rg --add-type 'custom:*mypersonalglob*' --type custom ...

Research with customized arguments

If none of the preset meet your requirements, color-rg-customized-search can release the full power of rg.

When color-rg-customized-search is called, the full command of rg will show up, and you can add any argument to rg as in shell.

you must escape special characters when using color-rg-customized-search, for example:

rg --type-add custom\:\*.el
# or
rg --type-add 'custom:*.el'
# or
rg --type-add "custom:*.el"

Contributor

More Repositories

1

lazycat-emacs

Andy Stewart's emacs
Emacs Lisp
425
star
2

aweshell

Awesome shell extension base on eshell with wonderful features!
Emacs Lisp
395
star
3

snails

A modern, easy-to-expand fuzzy search framework
Emacs Lisp
386
star
4

awesome-tab

Emacs package to provide out-of-the-box configuration to use tabs.
Emacs Lisp
364
star
5

deepin-terminal

Deepin Terminal written by vala
Vala
257
star
6

awesome-tray

Hide mode-line, display necessary information at right of minibuffer.
Emacs Lisp
233
star
7

nox

Nox is a lightweight, high-performance LSP client for Emacs
Emacs Lisp
206
star
8

popweb

Show popup web window for Emacs
JavaScript
142
star
9

mind-wave

Emacs AI plugin based on ChatGPT API
Emacs Lisp
137
star
10

company-english-helper

English helper base on Emacs company-mode
Emacs Lisp
99
star
11

insert-translated-name

Insert translated string as variable or function name
Emacs Lisp
87
star
12

awesome-pair

Auto parenthesis pairing with syntax table
Emacs Lisp
76
star
13

auto-save

Automatically save files without temporary files to protect your finger. ;)
Emacs Lisp
73
star
14

blink-search

In the blink of an eye, the search is complete
Emacs Lisp
72
star
15

sdcv

Emacs interface for sdcv (Stardict console version)
Emacs Lisp
64
star
16

deno-bridge

Build bridge between Emacs and Deno, execution of JavaScript and Typescript within Emacs.
Emacs Lisp
59
star
17

deepin-software-center

Software center for linux deepin.
Python
51
star
18

manateelazycat.github.io

My personal blog
HTML
50
star
19

deepin-screen-recorder

Deepin screen recorder
C++
50
star
20

holo-layer

HoloLayer is a multimedia layer plugin designed specifically for Emacs
Emacs Lisp
48
star
21

grammatical-edit

Grammatical edit base on tree-sitter
Emacs Lisp
47
star
22

hammerspoon-config

My config for Hammerspoon Window Manager
Lua
46
star
23

thing-edit

Copy and paste anything under cursor.
Emacs Lisp
46
star
24

sort-tab

Smarter tab solution for Emacs, sort tab with using frequency.
Emacs Lisp
44
star
25

deepin-system-monitor

System monitor for deepin
C++
41
star
26

instant-rename-tag

Instant rename tag
Emacs Lisp
32
star
27

python-bridge

Write Emacs Plugin by Python, split code from EAF.
Emacs Lisp
32
star
28

lazy-load

Lazy load keys for speed ​​up Emacs startup.
Emacs Lisp
30
star
29

deepin-pinyin-assistant

Deepin pinyin assistant
C
27
star
30

fingertip

Fingertip is struct edit plugin that base on treesit
Emacs Lisp
26
star
31

deepin-editor

Simple note application for deepin
C++
24
star
32

markmacro

Keyboard macro for marked regions
Emacs Lisp
21
star
33

one-key

Many commands share one key.
Emacs Lisp
20
star
34

mrkeyboard

Mr. Keyboard
Vala
17
star
35

grep-dired

Find name with given regexp, and show in dired.
Emacs Lisp
16
star
36

lazycat-theme

Cool hacker's emacs theme, but won't hurt your eye
Emacs Lisp
16
star
37

nova

Nova is a multi-threaded remote access plugin designed specifically for Emacs, with outstanding file synchronization performance.
Emacs Lisp
16
star
38

multi-term

Managing multiple terminal buffers in Emacs.
Emacs Lisp
15
star
39

corfu-english-helper

English helper for Emacs, base on corfu-mode
Emacs Lisp
15
star
40

deepin-voice-recorder

Voice recorder application for deepin
C++
15
star
41

lazy-search

Mark current symbol and jump in all matching symbols.
Emacs Lisp
15
star
42

lsp-bridge

Fastest LSP client for Emacs, work in progress...
Python
14
star
43

deepin-picker

Color picker tool for deepin
C++
13
star
44

css-sort

An Emacs extension you can sort CSS attributables automatically.
Emacs Lisp
13
star
45

tower-ng

Use rails write web todo-list tool like https://tower.im, this project is just a learning project
Ruby
12
star
46

smart-align

Smart align block around cursor
Emacs Lisp
11
star
47

delete-block

Delete block effectively
Emacs Lisp
10
star
48

recursive-search-references

Find function references in directory
Emacs Lisp
9
star
49

deepin-desktop-monitor

Deepin Desktop Monitor
C++
8
star
50

key-echo

Key-Echo is an Emacs plugin that uses XRecord technology to listen to system key events
Emacs Lisp
8
star
51

highlight-matching-tag

This plugin will highlight matching tag instantaneously.
Emacs Lisp
8
star
52

bison

Mode to editing bision source code in Emacs
Emacs Lisp
8
star
53

wraplish

Wraplish 是一个在 Unicode 与英文之间加上空格的Emacs插件,
Emacs Lisp
7
star
54

duplicate-line

Duplicate line or region, don't need move cursor.
Emacs Lisp
7
star
55

flex

It's a mode for flex files that provide better syntax highlight than flex-mode.el
Emacs Lisp
7
star
56

watch-other-window

Scroll other window and keep current window's position.
Emacs Lisp
7
star
57

find-define

Jump to the definition of a function or variable
Emacs Lisp
6
star
58

deepin-gnome-shell-3.4.1

Deepin gnome shell 3.4.1
C
6
star
59

move-text

Move current line or region
Emacs Lisp
6
star
60

deepin-translate-tools

Translate tools for deepin linux.
Python
6
star
61

vi-navigate

Navigate read-only buffer like vi behavior.
Emacs Lisp
6
star
62

html-to-word

This is a HTML to Word conversion library for Rails.
Ruby
6
star
63

manateelazycat

Github profile repo
5
star
64

cache-path-from-shell

Provide a chache mechanism make sure exec-path-from-shell just execute once.
Emacs Lisp
5
star
65

find-orphan

Find orphan function that need remove
Emacs Lisp
5
star
66

open-newline

Open newline like vi.
Emacs Lisp
4
star
67

toggle-one-window

Toggle between window layout and one window.
Emacs Lisp
4
star
68

lazycat-gs-theme

Gnome shell for my own use
Shell
3
star
69

manatee

Manatee Integrate Live Environment
Haskell
3
star
70

deb2po

Convert format between *.debian and *.po file.
Python
3
star
71

effortless-indent

Indent paste code without additional selection operations
Emacs Lisp
3
star
72

lazycat-emacs-time-machine

The elisp code that has been tossed, no longer used, archived to commemorate
Emacs Lisp
3
star
73

deno-bridge-ts

Build bridge between Emacs and Deno, execution of JavaScript and Typescript within Emacs, this repo is TypeScript part for deno-bridge
TypeScript
1
star