SlideShare une entreprise Scribd logo
1  sur  31
Télécharger pour lire hors ligne
Search and Replacement Techniques
avy, swiper, multiple-cursor, ag, and wgrep
Kazuki Yoshida
September 18, 2017
Boston Emacs Meetup
1 / 31
Who Am I?
▶ Doctoral student at Harvard T.H. Chan School of Public
Health (Epidemiology & Biostatistics).
▶ emacs user since 2012.
▶ Main use of emacs: R programming and LATEX.
▶ Maintainer of eval-in-repl and
reveal-in-osx-finder on MELPA.
▶ Co-organizer of Boston Emacs Meetup since 2017.
2 / 31
Packages Mentioned
▶ avy: https://github.com/abo-abo/avy
▶ swiper/counsel/ivy:
https://github.com/abo-abo/swiper
▶ multiple-cursor: https://github.com/magnars/
multiple-cursors.el
▶ ag: https://github.com/Wilfred/ag.el
▶ rg: https://github.com/dajva/rg.el
▶ wgrep: https:
//github.com/mhayashi1120/Emacs-wgrep
▶ command-log-mode: https:
//github.com/lewang/command-log-mode
3 / 31
Demonstration Environment
▶ MacBook Air (13-inch, Mid 2012)
▶ macOS Sierra 10.12.6
▶ emacs-plus 26.0.50
brew install emacs-plus
--with-natural-title-bar --HEAD
▶ Beamer slides exported via org-beamer and
org-mode 9.0.9
4 / 31
5 / 31
6 / 31
What is it?
▶ "Jump to things in Emacs tree-style"
▶ Repo: https://github.com/abo-abo/avy
▶ Video: https:
//www.youtube.com/watch?v=ziytRbASKeU
▶ Purpose: Move the cursor to anywhere visible by
"searching".
7 / 31
Example Workflow
▶ Meta-x avy-goto-char to invoke on a specified
character (prompt)
▶ Meta-x avy-goto-char-timer to invoke after
multiple characters (prompt)
▶ Meta-x avy-goto-word-1 to invoke on a specified
character at the word beginning (prompt)
▶ Meta-x avy-goto-line to invoke on all lines (no
prompt)
▶ Meta-x avy-isearch (Ctrl-’) to transition from
isearch to avy (no prompt)
I personally use a hack for avy-goto-char to avoid the
prompt asking for a character. For example, Meta-super-a
invokes directly (avy-goto-char ?a) without having to
enter a in the prompt.
8 / 31
(use-package avy
:demand
:bind (:map isearch-mode-map
("C-’" . avy-isearch))
:config
;; Darken background.
(setq avy-background t)
;; Highlight the first decision char with ‘avy-lead-face-0’.
;; https://github.com/abo-abo/avy/wiki/defcustom#avy-highlight-first
(setq avy-highlight-first t)
;; The default method of displaying the overlays.
;; https://github.com/abo-abo/avy/wiki/defcustom#avy-style
(setq avy-style ’at-full)
;; Keys to be used. Use a-z.
(setq avy-keys (loop for c from ?a to ?z collect c))
;; Time out for *-timer functions
(setq avy-timeout-seconds 0.3)
;;
;; one-step activation https://github.com/cjohansen/.emacs.d/commit/65efe88
(defun add-keys-to-avy (prefix c &optional mode)
(define-key global-map
(read-kbd-macro (concat prefix (string c)))
‘(lambda ()
(interactive)
(funcall (cond
;; Word beginning
((eq ’,mode ’word) #’avy-goto-word-1)
;; Anywhere
(t #’avy-goto-char))
,c))))
;; Assing key bindings for all characters
;; eg, M-s-a will activate (avy-goto-char ?a), ie, all occurrence of a
(loop for c from ?! to ?~ do (add-keys-to-avy "M-s-" c))
;; eg, C-M-s-a will activate (avy-goto-word-1 ?a), ie, all words starting with a
(loop for c from ?! to ?~ do (add-keys-to-avy "C-M-s-" c ’word)))
9 / 31
10 / 31
11 / 31
What is it?
▶ "Alternative to isearch that uses ivy to show an overview
of all matches"
▶ Repo: https:
//github.com/abo-abo/swiper#swiper
▶ Video: https:
//www.youtube.com/watch?v=0mwwN0S1dnQ
▶ Purpose: Within-buffer searching for the current buffer
12 / 31
Example Workflow
▶ Meta-x swiper to start from an empty search string
▶ Meta-x swiper-from-isearch to transition from
isearch to swiper
▶ Meta-x ivy-avy (Ctrl-’) to use avy to choose
▶ Meta-x ivy-occur (Ctrl-c Ctrl-o) to create a
dedicated buffer of the search results
▶ Meta-x ivy-wgrep-change-to-wgrep-mode
(Ctrl-x Ctrl-q) to start editing the results
▶ Meta-x wgrep-finish-edit (Ctrl-c Ctrl-c)
to save the changes
I defined an enhanced function swiper-at-point, which
pick up the symbol at point or the selected region if available
as the initial search term.
13 / 31
;; https://www.gnu.org/software/emacs/manual/html_node/elisp/Recursive-Mini.html
(setq enable-recursive-minibuffers t)
(use-package swiper
:commands (swiper
swiper-at-point)
:bind (("s-s" . swiper-at-point)
("C-s-s" . swiper)
;; Add bindings to isearch-mode
:map isearch-mode-map
("s-s" . swiper-from-isearch))
:init
;; Newly defined
(defun swiper-at-point ()
"Custom function to pick up a thing at a point for swiper
If a selected region exists, it will be searched for by swiper
If there is a symbol at the current point, its textual representation is
searched. If there is no symbol, empty search box is started."
(interactive)
(swiper (selection-or-thing-at-point))))
(defun selection-or-thing-at-point ()
(cond
;; If there is selection use it
((and transient-mark-mode
mark-active
(not (eq (mark) (point))))
(let ((mark-saved (mark))
(point-saved (point)))
(deactivate-mark)
(buffer-substring-no-properties mark-saved point-saved)))
;; Otherwise, use symbol at point or empty
(t (format "%s"
(or (thing-at-point ’symbol)
"")))))
14 / 31
Swiper-Helm
15 / 31
16 / 31
What is it?
▶ "Helm version of swiper"
▶ Repo:
https://github.com/abo-abo/swiper-helm
▶ Purpose: Within-buffer searching for the current buffer
17 / 31
Example Workflow
▶ Meta-x swiper-helm to start from an empty search
string
▶ Meta-x swiper-helm-from-isearch to
transition from isearch to swiper
▶ Ctrl-’ to use avy to choose (in
ace-jump-helm-line package)
▶ I couldn’t find editing capability.
I defined an enhanced function swiper-helm-at-point,
which pick up the symbol at point or the selected region if
available as the initial search term.
18 / 31
;; https://github.com/abo-abo/swiper-helm
(use-package swiper-helm
:commands (swiper-helm
swiper-helm-from-isearch)
:bind (("s-s" . swiper-helm-at-point)
("C-s-s" . swiper-helm)
:map isearch-mode-map
("s-s" . swiper-helm-from-isearch))
:config
(defun swiper-helm-at-point ()
"Custom function to pick up a thing at a point for swiper-helm
If a selected region exists, it will be searched for by swiper-helm
If there is a symbol at the current point, its textual representation is
searched. If there is no symbol, empty search box is started."
(interactive)
(swiper-helm (selection-or-thing-at-point))))
19 / 31
Multiple-Cursor
20 / 31
21 / 31
What is it?
▶ "Multiple cursors for emacs"
▶ Repo: https://github.com/magnars/
multiple-cursors.el
▶ Video: http://emacsrocks.com/e13.html
▶ Purpose: Live editing multiple places simultaneously
22 / 31
Example Workflow
▶ Meta-x mc/mark-next-like-this to add cursor
to the next occurrence of the selected text
▶ Meta-x mc/mark-all-like-this to add cursors
to all the occurrences of the selected text
▶ Meta-x mc/mark-next-symbol-like-this
same but limited to symbols
▶ Meta-x mc/mark-all-symbol-like-this same
but limited to symbols
▶ Meta-x mc/insert-numbers to insert consecutive
numbers at cursors
▶ Meta-x mc/insert-letters to insert consecutive
alphabet characters at cursors
23 / 31
(use-package multiple-cursors
:bind (;; highlighting symbols only
("C-M->" . mc/mark-next-symbol-like-this)
("C-M-<" . mc/mark-previous-symbol-like-this)
("C-M-*" . mc/mark-all-symbols-like-this)
;; highlighting all
("C->" . mc/mark-next-like-this)
("C-<" . mc/mark-previous-like-this)
("C-*" . mc/mark-all-like-this)))
24 / 31
Counsel-Ag
25 / 31
26 / 31
What is it?
▶ "Grep for a string in the current directory using ag"
▶ Repo: https:
//github.com/abo-abo/swiper#counsel
▶ Blog:
https://sam217pa.github.io/2016/09/11/
nuclear-power-editing-via-ivy-and-ag/
▶ Purpose: Multi-file search via ag command (brew
install the_silver_searcher) with optional
editing.
counsel-rg is essentially identical except for the use of rg
command (brew install ripgrep).
counsel-git-grep is very similar except that the back
end is git, and it is project-folder-aware. ag.el and rg.el
do not use the ivy live-filtering interface, but editing can
work similarly.
27 / 31
Example Workflow
▶ Meta-x counsel-ag to call with an empty string for
the current directory. The universal argument (Ctrl-u
before invocation) make it ask for the directory and
command-line arguments.
▶ Meta-x ivy-avy (Ctrl-’) to use avy to choose
▶ Meta-x ivy-occur (Ctrl-c Ctrl-o) to create a
dedicated buffer of the search results
▶ Meta-x ivy-wgrep-change-to-wgrep-mode
(Ctrl-x Ctrl-q) to start editing the results
▶ Edit using multiple-cursor
▶ Meta-x wgrep-finish-edit (Ctrl-c Ctrl-c)
to save the changes
I defined an enhanced function counsel-ag-at-point,
which pick up the symbol at point or the selected region if
available as the initial search term and is project-folder-aware.
28 / 31
(use-package counsel
:commands (counsel-ag
counsel-ag-at-point
counsel-git-grep)
:bind (("s-q". counsel-ag-at-point)
("C-s-q" . counsel-ag))
:config
;; Use this filter advice to always use ag at the project root.
(defun counsel-ag-arg2-to-project-root (args)
‘(,(car args)
,(projectile-project-root)
,@(cddr args)))
;; (advice-add #’counsel-ag :filter-args #’counsel-ag-arg2-to-project-root)
;; (advice-remove #’counsel-ag #’counsel-ag-arg2-to-project-root)
;;
(defun counsel-ag-at-point ()
(interactive)
(counsel-ag (selection-or-thing-at-point)
(projectile-project-root)))
;;
(defun counsel-rg-at-point ()
(interactive)
(counsel-rg (selection-or-thing-at-point)
(projectile-project-root)))
;;
(defun counsel-git-grep-at-point ()
(interactive)
(counsel-git-grep nil
(selection-or-thing-at-point))))
29 / 31
Summary: Current Buffer
▶ Meta-x swiper
▶ Meta-x ivy-occur (Ctrl-c Ctrl-o)
▶ Meta-x ivy-wgrep-change-to-wgrep-mode
(Ctrl-x Ctrl-q)
▶ multiple-cursor can help here.
▶ Meta-x wgrep-finish-edit (Ctrl-c Ctrl-c)
30 / 31
Summary: Multiple Files
▶ Either one of
▶ Meta-x counsel-ag
▶ Meta-x counsel-rg
▶ Meta-x counsel-git-grep
▶ Meta-x ivy-occur (Ctrl-c Ctrl-o)
▶ Meta-x ivy-wgrep-change-to-wgrep-mode
(Ctrl-x Ctrl-q)
▶ multiple-cursor can help here.
▶ Meta-x wgrep-finish-edit (Ctrl-c Ctrl-c)
31 / 31

Contenu connexe

Tendances

Deep Learningによる超解像の進歩
Deep Learningによる超解像の進歩Deep Learningによる超解像の進歩
Deep Learningによる超解像の進歩Hiroto Honda
 
1072: アプリケーション開発を加速するCUDAライブラリ
1072: アプリケーション開発を加速するCUDAライブラリ1072: アプリケーション開発を加速するCUDAライブラリ
1072: アプリケーション開発を加速するCUDAライブラリNVIDIA Japan
 
高速フーリエ変換
高速フーリエ変換高速フーリエ変換
高速フーリエ変換AtCoder Inc.
 
Boost.Preprocessorでプログラミングしましょう
Boost.PreprocessorでプログラミングしましょうBoost.Preprocessorでプログラミングしましょう
Boost.Preprocessorでプログラミングしましょうdigitalghost
 
Rove / Testing is a pity in Common Lisp
Rove / Testing is a pity in Common LispRove / Testing is a pity in Common Lisp
Rove / Testing is a pity in Common Lispfukamachi
 
2018 builderscon airflowを用いて、 複雑大規模なジョブフロー管理 に立ち向かう
2018 builderscon airflowを用いて、 複雑大規模なジョブフロー管理 に立ち向かう2018 builderscon airflowを用いて、 複雑大規模なジョブフロー管理 に立ち向かう
2018 builderscon airflowを用いて、 複雑大規模なジョブフロー管理 に立ち向かうBrainPad Inc.
 
ナレッジグラフ/LOD利用技術の入門(後編)
ナレッジグラフ/LOD利用技術の入門(後編)ナレッジグラフ/LOD利用技術の入門(後編)
ナレッジグラフ/LOD利用技術の入門(後編)KnowledgeGraph
 
局所環と非単元の集合 Local ring
局所環と非単元の集合 Local ring局所環と非単元の集合 Local ring
局所環と非単元の集合 Local ringHanpenRobot
 
複素数・四元数と図形の回転
複素数・四元数と図形の回転複素数・四元数と図形の回転
複素数・四元数と図形の回転Yoshihiro Mizoguchi
 
ナレッジグラフ/LOD利用技術の入門(前編)
ナレッジグラフ/LOD利用技術の入門(前編)ナレッジグラフ/LOD利用技術の入門(前編)
ナレッジグラフ/LOD利用技術の入門(前編)KnowledgeGraph
 
Categorical reparameterization with gumbel softmax
Categorical reparameterization with gumbel softmaxCategorical reparameterization with gumbel softmax
Categorical reparameterization with gumbel softmaxぱんいち すみもと
 
PYNQ 祭り: Pmod のプログラミング
PYNQ 祭り: Pmod のプログラミングPYNQ 祭り: Pmod のプログラミング
PYNQ 祭り: Pmod のプログラミングryos36
 
Ruby で高速なプログラムを書く
Ruby で高速なプログラムを書くRuby で高速なプログラムを書く
Ruby で高速なプログラムを書くmametter
 
Sift特徴量について
Sift特徴量についてSift特徴量について
Sift特徴量についてla_flance
 
凸最適化 〜 双対定理とソルバーCVXPYの紹介 〜
凸最適化 〜 双対定理とソルバーCVXPYの紹介 〜凸最適化 〜 双対定理とソルバーCVXPYの紹介 〜
凸最適化 〜 双対定理とソルバーCVXPYの紹介 〜Tomoki Yoshida
 
x86x64 SSE4.2 POPCNT
x86x64 SSE4.2 POPCNTx86x64 SSE4.2 POPCNT
x86x64 SSE4.2 POPCNTtakesako
 
感情の出どころを探る、一歩進んだ感情解析
感情の出どころを探る、一歩進んだ感情解析感情の出どころを探る、一歩進んだ感情解析
感情の出どころを探る、一歩進んだ感情解析Takahiro Kubo
 
ナレッジグラフとオントロジー
ナレッジグラフとオントロジーナレッジグラフとオントロジー
ナレッジグラフとオントロジーUniversity of Tsukuba
 

Tendances (20)

Deep Learningによる超解像の進歩
Deep Learningによる超解像の進歩Deep Learningによる超解像の進歩
Deep Learningによる超解像の進歩
 
1072: アプリケーション開発を加速するCUDAライブラリ
1072: アプリケーション開発を加速するCUDAライブラリ1072: アプリケーション開発を加速するCUDAライブラリ
1072: アプリケーション開発を加速するCUDAライブラリ
 
高速フーリエ変換
高速フーリエ変換高速フーリエ変換
高速フーリエ変換
 
Boost.Preprocessorでプログラミングしましょう
Boost.PreprocessorでプログラミングしましょうBoost.Preprocessorでプログラミングしましょう
Boost.Preprocessorでプログラミングしましょう
 
Rove / Testing is a pity in Common Lisp
Rove / Testing is a pity in Common LispRove / Testing is a pity in Common Lisp
Rove / Testing is a pity in Common Lisp
 
2018 builderscon airflowを用いて、 複雑大規模なジョブフロー管理 に立ち向かう
2018 builderscon airflowを用いて、 複雑大規模なジョブフロー管理 に立ち向かう2018 builderscon airflowを用いて、 複雑大規模なジョブフロー管理 に立ち向かう
2018 builderscon airflowを用いて、 複雑大規模なジョブフロー管理 に立ち向かう
 
ナレッジグラフ/LOD利用技術の入門(後編)
ナレッジグラフ/LOD利用技術の入門(後編)ナレッジグラフ/LOD利用技術の入門(後編)
ナレッジグラフ/LOD利用技術の入門(後編)
 
局所環と非単元の集合 Local ring
局所環と非単元の集合 Local ring局所環と非単元の集合 Local ring
局所環と非単元の集合 Local ring
 
複素数・四元数と図形の回転
複素数・四元数と図形の回転複素数・四元数と図形の回転
複素数・四元数と図形の回転
 
ナレッジグラフ/LOD利用技術の入門(前編)
ナレッジグラフ/LOD利用技術の入門(前編)ナレッジグラフ/LOD利用技術の入門(前編)
ナレッジグラフ/LOD利用技術の入門(前編)
 
RAPIDS 概要
RAPIDS 概要RAPIDS 概要
RAPIDS 概要
 
Categorical reparameterization with gumbel softmax
Categorical reparameterization with gumbel softmaxCategorical reparameterization with gumbel softmax
Categorical reparameterization with gumbel softmax
 
PYNQ 祭り: Pmod のプログラミング
PYNQ 祭り: Pmod のプログラミングPYNQ 祭り: Pmod のプログラミング
PYNQ 祭り: Pmod のプログラミング
 
サンプリング定理
サンプリング定理サンプリング定理
サンプリング定理
 
Ruby で高速なプログラムを書く
Ruby で高速なプログラムを書くRuby で高速なプログラムを書く
Ruby で高速なプログラムを書く
 
Sift特徴量について
Sift特徴量についてSift特徴量について
Sift特徴量について
 
凸最適化 〜 双対定理とソルバーCVXPYの紹介 〜
凸最適化 〜 双対定理とソルバーCVXPYの紹介 〜凸最適化 〜 双対定理とソルバーCVXPYの紹介 〜
凸最適化 〜 双対定理とソルバーCVXPYの紹介 〜
 
x86x64 SSE4.2 POPCNT
x86x64 SSE4.2 POPCNTx86x64 SSE4.2 POPCNT
x86x64 SSE4.2 POPCNT
 
感情の出どころを探る、一歩進んだ感情解析
感情の出どころを探る、一歩進んだ感情解析感情の出どころを探る、一歩進んだ感情解析
感情の出どころを探る、一歩進んだ感情解析
 
ナレッジグラフとオントロジー
ナレッジグラフとオントロジーナレッジグラフとオントロジー
ナレッジグラフとオントロジー
 

Similaire à Search and Replacement Techniques in Emacs: avy, swiper, multiple-cursor, ag, and wgrep.

Building resilient services in go
Building resilient services in goBuilding resilient services in go
Building resilient services in goJaehue Jang
 
A Recovering Java Developer Learns to Go
A Recovering Java Developer Learns to GoA Recovering Java Developer Learns to Go
A Recovering Java Developer Learns to GoMatt Stine
 
"今" 使えるJavaScriptのトレンド
"今" 使えるJavaScriptのトレンド"今" 使えるJavaScriptのトレンド
"今" 使えるJavaScriptのトレンドHayato Mizuno
 
Go 1.10 Release Party - PDX Go
Go 1.10 Release Party - PDX GoGo 1.10 Release Party - PDX Go
Go 1.10 Release Party - PDX GoRodolfo Carvalho
 
Automate Yo'self -- SeaGL
Automate Yo'self -- SeaGL Automate Yo'self -- SeaGL
Automate Yo'self -- SeaGL John Anderson
 
Ratpack - Classy and Compact Groovy Web Apps
Ratpack - Classy and Compact Groovy Web AppsRatpack - Classy and Compact Groovy Web Apps
Ratpack - Classy and Compact Groovy Web AppsJames Williams
 
[MeetUp][2nd] 컭on턺
[MeetUp][2nd] 컭on턺[MeetUp][2nd] 컭on턺
[MeetUp][2nd] 컭on턺InfraEngineer
 
Concurrency in go
Concurrency in goConcurrency in go
Concurrency in goborderj
 
DevSecCon London 2017 - MacOS security, hardening and forensics 101 by Ben Hu...
DevSecCon London 2017 - MacOS security, hardening and forensics 101 by Ben Hu...DevSecCon London 2017 - MacOS security, hardening and forensics 101 by Ben Hu...
DevSecCon London 2017 - MacOS security, hardening and forensics 101 by Ben Hu...DevSecCon
 
Hacking with ruby2ruby
Hacking with ruby2rubyHacking with ruby2ruby
Hacking with ruby2rubyMarc Chung
 
Advanced debugging  techniques in different environments
Advanced debugging  techniques in different environmentsAdvanced debugging  techniques in different environments
Advanced debugging  techniques in different environmentsAndrii Soldatenko
 
Inside the JVM - Follow the white rabbit!
Inside the JVM - Follow the white rabbit!Inside the JVM - Follow the white rabbit!
Inside the JVM - Follow the white rabbit!Sylvain Wallez
 
2015-GopherCon-Talk-Uptime.pdf
2015-GopherCon-Talk-Uptime.pdf2015-GopherCon-Talk-Uptime.pdf
2015-GopherCon-Talk-Uptime.pdfUtabeUtabe
 
Hands on clang-format
Hands on clang-formatHands on clang-format
Hands on clang-formatKai Wolf
 
[Golang] 以 Mobile App 工程師視角,帶你進入 Golang 的世界 (Introduction of GoLang)
[Golang] 以 Mobile App 工程師視角,帶你進入 Golang 的世界 (Introduction of GoLang) [Golang] 以 Mobile App 工程師視角,帶你進入 Golang 的世界 (Introduction of GoLang)
[Golang] 以 Mobile App 工程師視角,帶你進入 Golang 的世界 (Introduction of GoLang) Johnny Sung
 

Similaire à Search and Replacement Techniques in Emacs: avy, swiper, multiple-cursor, ag, and wgrep. (20)

Building resilient services in go
Building resilient services in goBuilding resilient services in go
Building resilient services in go
 
A Recovering Java Developer Learns to Go
A Recovering Java Developer Learns to GoA Recovering Java Developer Learns to Go
A Recovering Java Developer Learns to Go
 
"今" 使えるJavaScriptのトレンド
"今" 使えるJavaScriptのトレンド"今" 使えるJavaScriptのトレンド
"今" 使えるJavaScriptのトレンド
 
Go 1.10 Release Party - PDX Go
Go 1.10 Release Party - PDX GoGo 1.10 Release Party - PDX Go
Go 1.10 Release Party - PDX Go
 
Automate Yo'self -- SeaGL
Automate Yo'self -- SeaGL Automate Yo'self -- SeaGL
Automate Yo'self -- SeaGL
 
Go. Why it goes
Go. Why it goesGo. Why it goes
Go. Why it goes
 
Automate Yo' Self
Automate Yo' SelfAutomate Yo' Self
Automate Yo' Self
 
Ratpack - Classy and Compact Groovy Web Apps
Ratpack - Classy and Compact Groovy Web AppsRatpack - Classy and Compact Groovy Web Apps
Ratpack - Classy and Compact Groovy Web Apps
 
[MeetUp][2nd] 컭on턺
[MeetUp][2nd] 컭on턺[MeetUp][2nd] 컭on턺
[MeetUp][2nd] 컭on턺
 
Concurrency in go
Concurrency in goConcurrency in go
Concurrency in go
 
DevSecCon London 2017 - MacOS security, hardening and forensics 101 by Ben Hu...
DevSecCon London 2017 - MacOS security, hardening and forensics 101 by Ben Hu...DevSecCon London 2017 - MacOS security, hardening and forensics 101 by Ben Hu...
DevSecCon London 2017 - MacOS security, hardening and forensics 101 by Ben Hu...
 
Hacking with ruby2ruby
Hacking with ruby2rubyHacking with ruby2ruby
Hacking with ruby2ruby
 
Advanced debugging  techniques in different environments
Advanced debugging  techniques in different environmentsAdvanced debugging  techniques in different environments
Advanced debugging  techniques in different environments
 
Vim Hacks
Vim HacksVim Hacks
Vim Hacks
 
Vim Hacks
Vim HacksVim Hacks
Vim Hacks
 
Inside the JVM - Follow the white rabbit!
Inside the JVM - Follow the white rabbit!Inside the JVM - Follow the white rabbit!
Inside the JVM - Follow the white rabbit!
 
2015-GopherCon-Talk-Uptime.pdf
2015-GopherCon-Talk-Uptime.pdf2015-GopherCon-Talk-Uptime.pdf
2015-GopherCon-Talk-Uptime.pdf
 
Hands on clang-format
Hands on clang-formatHands on clang-format
Hands on clang-format
 
[Golang] 以 Mobile App 工程師視角,帶你進入 Golang 的世界 (Introduction of GoLang)
[Golang] 以 Mobile App 工程師視角,帶你進入 Golang 的世界 (Introduction of GoLang) [Golang] 以 Mobile App 工程師視角,帶你進入 Golang 的世界 (Introduction of GoLang)
[Golang] 以 Mobile App 工程師視角,帶你進入 Golang 的世界 (Introduction of GoLang)
 
Elixir on Containers
Elixir on ContainersElixir on Containers
Elixir on Containers
 

Plus de Kazuki Yoshida

Graphical explanation of causal mediation analysis
Graphical explanation of causal mediation analysisGraphical explanation of causal mediation analysis
Graphical explanation of causal mediation analysisKazuki Yoshida
 
Pharmacoepidemiology Lecture: Designing Observational CER to Emulate an RCT
Pharmacoepidemiology Lecture: Designing Observational CER to Emulate an RCTPharmacoepidemiology Lecture: Designing Observational CER to Emulate an RCT
Pharmacoepidemiology Lecture: Designing Observational CER to Emulate an RCTKazuki Yoshida
 
What is the Expectation Maximization (EM) Algorithm?
What is the Expectation Maximization (EM) Algorithm?What is the Expectation Maximization (EM) Algorithm?
What is the Expectation Maximization (EM) Algorithm?Kazuki Yoshida
 
Propensity Score Methods for Comparative Effectiveness Research with Multiple...
Propensity Score Methods for Comparative Effectiveness Research with Multiple...Propensity Score Methods for Comparative Effectiveness Research with Multiple...
Propensity Score Methods for Comparative Effectiveness Research with Multiple...Kazuki Yoshida
 
Visual Explanation of Ridge Regression and LASSO
Visual Explanation of Ridge Regression and LASSOVisual Explanation of Ridge Regression and LASSO
Visual Explanation of Ridge Regression and LASSOKazuki Yoshida
 
ENAR 2018 Matching Weights to Simultaneously Compare Three Treatment Groups: ...
ENAR 2018 Matching Weights to Simultaneously Compare Three Treatment Groups: ...ENAR 2018 Matching Weights to Simultaneously Compare Three Treatment Groups: ...
ENAR 2018 Matching Weights to Simultaneously Compare Three Treatment Groups: ...Kazuki Yoshida
 
Comparison of Privacy-Protecting Analytic and Data-sharing Methods: a Simulat...
Comparison of Privacy-Protecting Analytic and Data-sharing Methods: a Simulat...Comparison of Privacy-Protecting Analytic and Data-sharing Methods: a Simulat...
Comparison of Privacy-Protecting Analytic and Data-sharing Methods: a Simulat...Kazuki Yoshida
 
Spacemacs: emacs user's first impression
Spacemacs: emacs user's first impressionSpacemacs: emacs user's first impression
Spacemacs: emacs user's first impressionKazuki Yoshida
 
Matching Weights to Simultaneously Compare Three Treatment Groups: a Simulati...
Matching Weights to Simultaneously Compare Three Treatment Groups: a Simulati...Matching Weights to Simultaneously Compare Three Treatment Groups: a Simulati...
Matching Weights to Simultaneously Compare Three Treatment Groups: a Simulati...Kazuki Yoshida
 
Multiple Imputation: Joint and Conditional Modeling of Missing Data
Multiple Imputation: Joint and Conditional Modeling of Missing DataMultiple Imputation: Joint and Conditional Modeling of Missing Data
Multiple Imputation: Joint and Conditional Modeling of Missing DataKazuki Yoshida
 
20130222 Data structures and manipulation in R
20130222 Data structures and manipulation in R20130222 Data structures and manipulation in R
20130222 Data structures and manipulation in RKazuki Yoshida
 
20130215 Reading data into R
20130215 Reading data into R20130215 Reading data into R
20130215 Reading data into RKazuki Yoshida
 
Linear regression with R 2
Linear regression with R 2Linear regression with R 2
Linear regression with R 2Kazuki Yoshida
 
Linear regression with R 1
Linear regression with R 1Linear regression with R 1
Linear regression with R 1Kazuki Yoshida
 
(Very) Basic graphing with R
(Very) Basic graphing with R(Very) Basic graphing with R
(Very) Basic graphing with RKazuki Yoshida
 
Introduction to Deducer
Introduction to DeducerIntroduction to Deducer
Introduction to DeducerKazuki Yoshida
 
Groupwise comparison of continuous data
Groupwise comparison of continuous dataGroupwise comparison of continuous data
Groupwise comparison of continuous dataKazuki Yoshida
 
Categorical data with R
Categorical data with RCategorical data with R
Categorical data with RKazuki Yoshida
 
Install and Configure R and RStudio
Install and Configure R and RStudioInstall and Configure R and RStudio
Install and Configure R and RStudioKazuki Yoshida
 

Plus de Kazuki Yoshida (20)

Graphical explanation of causal mediation analysis
Graphical explanation of causal mediation analysisGraphical explanation of causal mediation analysis
Graphical explanation of causal mediation analysis
 
Pharmacoepidemiology Lecture: Designing Observational CER to Emulate an RCT
Pharmacoepidemiology Lecture: Designing Observational CER to Emulate an RCTPharmacoepidemiology Lecture: Designing Observational CER to Emulate an RCT
Pharmacoepidemiology Lecture: Designing Observational CER to Emulate an RCT
 
What is the Expectation Maximization (EM) Algorithm?
What is the Expectation Maximization (EM) Algorithm?What is the Expectation Maximization (EM) Algorithm?
What is the Expectation Maximization (EM) Algorithm?
 
Propensity Score Methods for Comparative Effectiveness Research with Multiple...
Propensity Score Methods for Comparative Effectiveness Research with Multiple...Propensity Score Methods for Comparative Effectiveness Research with Multiple...
Propensity Score Methods for Comparative Effectiveness Research with Multiple...
 
Emacs Key Bindings
Emacs Key BindingsEmacs Key Bindings
Emacs Key Bindings
 
Visual Explanation of Ridge Regression and LASSO
Visual Explanation of Ridge Regression and LASSOVisual Explanation of Ridge Regression and LASSO
Visual Explanation of Ridge Regression and LASSO
 
ENAR 2018 Matching Weights to Simultaneously Compare Three Treatment Groups: ...
ENAR 2018 Matching Weights to Simultaneously Compare Three Treatment Groups: ...ENAR 2018 Matching Weights to Simultaneously Compare Three Treatment Groups: ...
ENAR 2018 Matching Weights to Simultaneously Compare Three Treatment Groups: ...
 
Comparison of Privacy-Protecting Analytic and Data-sharing Methods: a Simulat...
Comparison of Privacy-Protecting Analytic and Data-sharing Methods: a Simulat...Comparison of Privacy-Protecting Analytic and Data-sharing Methods: a Simulat...
Comparison of Privacy-Protecting Analytic and Data-sharing Methods: a Simulat...
 
Spacemacs: emacs user's first impression
Spacemacs: emacs user's first impressionSpacemacs: emacs user's first impression
Spacemacs: emacs user's first impression
 
Matching Weights to Simultaneously Compare Three Treatment Groups: a Simulati...
Matching Weights to Simultaneously Compare Three Treatment Groups: a Simulati...Matching Weights to Simultaneously Compare Three Treatment Groups: a Simulati...
Matching Weights to Simultaneously Compare Three Treatment Groups: a Simulati...
 
Multiple Imputation: Joint and Conditional Modeling of Missing Data
Multiple Imputation: Joint and Conditional Modeling of Missing DataMultiple Imputation: Joint and Conditional Modeling of Missing Data
Multiple Imputation: Joint and Conditional Modeling of Missing Data
 
20130222 Data structures and manipulation in R
20130222 Data structures and manipulation in R20130222 Data structures and manipulation in R
20130222 Data structures and manipulation in R
 
20130215 Reading data into R
20130215 Reading data into R20130215 Reading data into R
20130215 Reading data into R
 
Linear regression with R 2
Linear regression with R 2Linear regression with R 2
Linear regression with R 2
 
Linear regression with R 1
Linear regression with R 1Linear regression with R 1
Linear regression with R 1
 
(Very) Basic graphing with R
(Very) Basic graphing with R(Very) Basic graphing with R
(Very) Basic graphing with R
 
Introduction to Deducer
Introduction to DeducerIntroduction to Deducer
Introduction to Deducer
 
Groupwise comparison of continuous data
Groupwise comparison of continuous dataGroupwise comparison of continuous data
Groupwise comparison of continuous data
 
Categorical data with R
Categorical data with RCategorical data with R
Categorical data with R
 
Install and Configure R and RStudio
Install and Configure R and RStudioInstall and Configure R and RStudio
Install and Configure R and RStudio
 

Dernier

GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jGraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jNeo4j
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesVictoriaMetrics
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdfAndrey Devyatkin
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingShane Coughlan
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...Bert Jan Schrijver
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencessuser9e7c64
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingShane Coughlan
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Rob Geurden
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolsosttopstonverter
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxRTS corp
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorTier1 app
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfmaor17
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesKrzysztofKkol1
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shardsChristopher Curtin
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slidesvaideheekore1
 

Dernier (20)

GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jGraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 Updates
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conference
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration tools
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryError
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdf
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slides
 

Search and Replacement Techniques in Emacs: avy, swiper, multiple-cursor, ag, and wgrep.

  • 1. Search and Replacement Techniques avy, swiper, multiple-cursor, ag, and wgrep Kazuki Yoshida September 18, 2017 Boston Emacs Meetup 1 / 31
  • 2. Who Am I? ▶ Doctoral student at Harvard T.H. Chan School of Public Health (Epidemiology & Biostatistics). ▶ emacs user since 2012. ▶ Main use of emacs: R programming and LATEX. ▶ Maintainer of eval-in-repl and reveal-in-osx-finder on MELPA. ▶ Co-organizer of Boston Emacs Meetup since 2017. 2 / 31
  • 3. Packages Mentioned ▶ avy: https://github.com/abo-abo/avy ▶ swiper/counsel/ivy: https://github.com/abo-abo/swiper ▶ multiple-cursor: https://github.com/magnars/ multiple-cursors.el ▶ ag: https://github.com/Wilfred/ag.el ▶ rg: https://github.com/dajva/rg.el ▶ wgrep: https: //github.com/mhayashi1120/Emacs-wgrep ▶ command-log-mode: https: //github.com/lewang/command-log-mode 3 / 31
  • 4. Demonstration Environment ▶ MacBook Air (13-inch, Mid 2012) ▶ macOS Sierra 10.12.6 ▶ emacs-plus 26.0.50 brew install emacs-plus --with-natural-title-bar --HEAD ▶ Beamer slides exported via org-beamer and org-mode 9.0.9 4 / 31
  • 7. What is it? ▶ "Jump to things in Emacs tree-style" ▶ Repo: https://github.com/abo-abo/avy ▶ Video: https: //www.youtube.com/watch?v=ziytRbASKeU ▶ Purpose: Move the cursor to anywhere visible by "searching". 7 / 31
  • 8. Example Workflow ▶ Meta-x avy-goto-char to invoke on a specified character (prompt) ▶ Meta-x avy-goto-char-timer to invoke after multiple characters (prompt) ▶ Meta-x avy-goto-word-1 to invoke on a specified character at the word beginning (prompt) ▶ Meta-x avy-goto-line to invoke on all lines (no prompt) ▶ Meta-x avy-isearch (Ctrl-’) to transition from isearch to avy (no prompt) I personally use a hack for avy-goto-char to avoid the prompt asking for a character. For example, Meta-super-a invokes directly (avy-goto-char ?a) without having to enter a in the prompt. 8 / 31
  • 9. (use-package avy :demand :bind (:map isearch-mode-map ("C-’" . avy-isearch)) :config ;; Darken background. (setq avy-background t) ;; Highlight the first decision char with ‘avy-lead-face-0’. ;; https://github.com/abo-abo/avy/wiki/defcustom#avy-highlight-first (setq avy-highlight-first t) ;; The default method of displaying the overlays. ;; https://github.com/abo-abo/avy/wiki/defcustom#avy-style (setq avy-style ’at-full) ;; Keys to be used. Use a-z. (setq avy-keys (loop for c from ?a to ?z collect c)) ;; Time out for *-timer functions (setq avy-timeout-seconds 0.3) ;; ;; one-step activation https://github.com/cjohansen/.emacs.d/commit/65efe88 (defun add-keys-to-avy (prefix c &optional mode) (define-key global-map (read-kbd-macro (concat prefix (string c))) ‘(lambda () (interactive) (funcall (cond ;; Word beginning ((eq ’,mode ’word) #’avy-goto-word-1) ;; Anywhere (t #’avy-goto-char)) ,c)))) ;; Assing key bindings for all characters ;; eg, M-s-a will activate (avy-goto-char ?a), ie, all occurrence of a (loop for c from ?! to ?~ do (add-keys-to-avy "M-s-" c)) ;; eg, C-M-s-a will activate (avy-goto-word-1 ?a), ie, all words starting with a (loop for c from ?! to ?~ do (add-keys-to-avy "C-M-s-" c ’word))) 9 / 31
  • 12. What is it? ▶ "Alternative to isearch that uses ivy to show an overview of all matches" ▶ Repo: https: //github.com/abo-abo/swiper#swiper ▶ Video: https: //www.youtube.com/watch?v=0mwwN0S1dnQ ▶ Purpose: Within-buffer searching for the current buffer 12 / 31
  • 13. Example Workflow ▶ Meta-x swiper to start from an empty search string ▶ Meta-x swiper-from-isearch to transition from isearch to swiper ▶ Meta-x ivy-avy (Ctrl-’) to use avy to choose ▶ Meta-x ivy-occur (Ctrl-c Ctrl-o) to create a dedicated buffer of the search results ▶ Meta-x ivy-wgrep-change-to-wgrep-mode (Ctrl-x Ctrl-q) to start editing the results ▶ Meta-x wgrep-finish-edit (Ctrl-c Ctrl-c) to save the changes I defined an enhanced function swiper-at-point, which pick up the symbol at point or the selected region if available as the initial search term. 13 / 31
  • 14. ;; https://www.gnu.org/software/emacs/manual/html_node/elisp/Recursive-Mini.html (setq enable-recursive-minibuffers t) (use-package swiper :commands (swiper swiper-at-point) :bind (("s-s" . swiper-at-point) ("C-s-s" . swiper) ;; Add bindings to isearch-mode :map isearch-mode-map ("s-s" . swiper-from-isearch)) :init ;; Newly defined (defun swiper-at-point () "Custom function to pick up a thing at a point for swiper If a selected region exists, it will be searched for by swiper If there is a symbol at the current point, its textual representation is searched. If there is no symbol, empty search box is started." (interactive) (swiper (selection-or-thing-at-point)))) (defun selection-or-thing-at-point () (cond ;; If there is selection use it ((and transient-mark-mode mark-active (not (eq (mark) (point)))) (let ((mark-saved (mark)) (point-saved (point))) (deactivate-mark) (buffer-substring-no-properties mark-saved point-saved))) ;; Otherwise, use symbol at point or empty (t (format "%s" (or (thing-at-point ’symbol) ""))))) 14 / 31
  • 17. What is it? ▶ "Helm version of swiper" ▶ Repo: https://github.com/abo-abo/swiper-helm ▶ Purpose: Within-buffer searching for the current buffer 17 / 31
  • 18. Example Workflow ▶ Meta-x swiper-helm to start from an empty search string ▶ Meta-x swiper-helm-from-isearch to transition from isearch to swiper ▶ Ctrl-’ to use avy to choose (in ace-jump-helm-line package) ▶ I couldn’t find editing capability. I defined an enhanced function swiper-helm-at-point, which pick up the symbol at point or the selected region if available as the initial search term. 18 / 31
  • 19. ;; https://github.com/abo-abo/swiper-helm (use-package swiper-helm :commands (swiper-helm swiper-helm-from-isearch) :bind (("s-s" . swiper-helm-at-point) ("C-s-s" . swiper-helm) :map isearch-mode-map ("s-s" . swiper-helm-from-isearch)) :config (defun swiper-helm-at-point () "Custom function to pick up a thing at a point for swiper-helm If a selected region exists, it will be searched for by swiper-helm If there is a symbol at the current point, its textual representation is searched. If there is no symbol, empty search box is started." (interactive) (swiper-helm (selection-or-thing-at-point)))) 19 / 31
  • 22. What is it? ▶ "Multiple cursors for emacs" ▶ Repo: https://github.com/magnars/ multiple-cursors.el ▶ Video: http://emacsrocks.com/e13.html ▶ Purpose: Live editing multiple places simultaneously 22 / 31
  • 23. Example Workflow ▶ Meta-x mc/mark-next-like-this to add cursor to the next occurrence of the selected text ▶ Meta-x mc/mark-all-like-this to add cursors to all the occurrences of the selected text ▶ Meta-x mc/mark-next-symbol-like-this same but limited to symbols ▶ Meta-x mc/mark-all-symbol-like-this same but limited to symbols ▶ Meta-x mc/insert-numbers to insert consecutive numbers at cursors ▶ Meta-x mc/insert-letters to insert consecutive alphabet characters at cursors 23 / 31
  • 24. (use-package multiple-cursors :bind (;; highlighting symbols only ("C-M->" . mc/mark-next-symbol-like-this) ("C-M-<" . mc/mark-previous-symbol-like-this) ("C-M-*" . mc/mark-all-symbols-like-this) ;; highlighting all ("C->" . mc/mark-next-like-this) ("C-<" . mc/mark-previous-like-this) ("C-*" . mc/mark-all-like-this))) 24 / 31
  • 27. What is it? ▶ "Grep for a string in the current directory using ag" ▶ Repo: https: //github.com/abo-abo/swiper#counsel ▶ Blog: https://sam217pa.github.io/2016/09/11/ nuclear-power-editing-via-ivy-and-ag/ ▶ Purpose: Multi-file search via ag command (brew install the_silver_searcher) with optional editing. counsel-rg is essentially identical except for the use of rg command (brew install ripgrep). counsel-git-grep is very similar except that the back end is git, and it is project-folder-aware. ag.el and rg.el do not use the ivy live-filtering interface, but editing can work similarly. 27 / 31
  • 28. Example Workflow ▶ Meta-x counsel-ag to call with an empty string for the current directory. The universal argument (Ctrl-u before invocation) make it ask for the directory and command-line arguments. ▶ Meta-x ivy-avy (Ctrl-’) to use avy to choose ▶ Meta-x ivy-occur (Ctrl-c Ctrl-o) to create a dedicated buffer of the search results ▶ Meta-x ivy-wgrep-change-to-wgrep-mode (Ctrl-x Ctrl-q) to start editing the results ▶ Edit using multiple-cursor ▶ Meta-x wgrep-finish-edit (Ctrl-c Ctrl-c) to save the changes I defined an enhanced function counsel-ag-at-point, which pick up the symbol at point or the selected region if available as the initial search term and is project-folder-aware. 28 / 31
  • 29. (use-package counsel :commands (counsel-ag counsel-ag-at-point counsel-git-grep) :bind (("s-q". counsel-ag-at-point) ("C-s-q" . counsel-ag)) :config ;; Use this filter advice to always use ag at the project root. (defun counsel-ag-arg2-to-project-root (args) ‘(,(car args) ,(projectile-project-root) ,@(cddr args))) ;; (advice-add #’counsel-ag :filter-args #’counsel-ag-arg2-to-project-root) ;; (advice-remove #’counsel-ag #’counsel-ag-arg2-to-project-root) ;; (defun counsel-ag-at-point () (interactive) (counsel-ag (selection-or-thing-at-point) (projectile-project-root))) ;; (defun counsel-rg-at-point () (interactive) (counsel-rg (selection-or-thing-at-point) (projectile-project-root))) ;; (defun counsel-git-grep-at-point () (interactive) (counsel-git-grep nil (selection-or-thing-at-point)))) 29 / 31
  • 30. Summary: Current Buffer ▶ Meta-x swiper ▶ Meta-x ivy-occur (Ctrl-c Ctrl-o) ▶ Meta-x ivy-wgrep-change-to-wgrep-mode (Ctrl-x Ctrl-q) ▶ multiple-cursor can help here. ▶ Meta-x wgrep-finish-edit (Ctrl-c Ctrl-c) 30 / 31
  • 31. Summary: Multiple Files ▶ Either one of ▶ Meta-x counsel-ag ▶ Meta-x counsel-rg ▶ Meta-x counsel-git-grep ▶ Meta-x ivy-occur (Ctrl-c Ctrl-o) ▶ Meta-x ivy-wgrep-change-to-wgrep-mode (Ctrl-x Ctrl-q) ▶ multiple-cursor can help here. ▶ Meta-x wgrep-finish-edit (Ctrl-c Ctrl-c) 31 / 31