forked from abo-abo/swiper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathivy.texi
1701 lines (1414 loc) · 50.4 KB
/
ivy.texi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
\input texinfo @c -*- texinfo -*-
@c %**start of header
@setfilename ./ivy.info
@settitle Ivy User Manual
@documentencoding UTF-8
@documentlanguage en
@c %**end of header
@copying
@ifnottex
Ivy manual, version 0.8.0
Ivy is an interactive interface for completion in Emacs. Emacs uses
completion mechanism in a variety of contexts: code, menus, commands,
variables, functions, etc. Completion entails listing, sorting,
filtering, previewing, and applying actions on selected items. When
active, @code{ivy-mode} completes the selection process by narrowing
available choices while previewing in the minibuffer. Selecting the
final candidate is either through simple keyboard character inputs or
through powerful regular expressions.
@end ifnottex
Copyright (C) 2015 Free Software Foundation, Inc.
@quotation
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
Invariant Sections, with the Front-Cover Texts being ``A GNU Manual,''
and with the Back-Cover Texts as in (a) below. A copy of the license
is included in the section entitled ``GNU Free Documentation License.''
(a) The FSF's Back-Cover Text is: ``You have the freedom to copy and
modify this GNU manual.''
@end quotation
@end copying
@dircategory Emacs
@direntry
* Ivy: (ivy). Using Ivy for completion.
@end direntry
@finalout
@titlepage
@title Ivy User Manual
@author Oleh Krehel
@page
@vskip 0pt plus 1filll
@insertcopying
@end titlepage
@contents
@ifnottex
@node Top
@top Ivy User Manual
@insertcopying
@end ifnottex
@menu
* Introduction::
* Installation::
* Getting started::
* Key bindings::
* Completion Styles::
* Customization::
* Commands::
* API::
* Variable Index::
* Keystroke Index::
@detailmenu
--- The Detailed Node Listing ---
Installation
* Installing from Emacs Package Manager::
* Installing from the Git repository::
Getting started
* Basic customization::
Key bindings
* Global key bindings::
* Minibuffer key bindings::
Minibuffer key bindings
* Key bindings for navigation::
* Key bindings for single selection, action, then exit minibuffer: Key bindings for single selection action then exit minibuffer.
* Key bindings for multiple selections and actions, keep minibuffer open: Key bindings for multiple selections and actions keep minibuffer open.
* Key bindings that alter the minibuffer input::
* Other key bindings::
* Hydra in the minibuffer::
* Saving the current completion session to a buffer::
Completion Styles
* ivy--regex-plus::
* ivy--regex-ignore-order::
* ivy--regex-fuzzy::
Customization
* Faces::
* Defcustoms::
* Actions::
* Packages::
Actions
* What are actions?::
* How can different actions be called?::
* How to modify the actions list?::
* Example - add two actions to each command::
* Example - define a new command with several actions::
Example - add two actions to each command
* How to undo adding the two actions::
* How to add actions to a specific command::
Example - define a new command with several actions
* Test the above function with @code{ivy-occur}::
Commands
* File Name Completion::
* Buffer Name Completion::
* Counsel commands::
API
* Required arguments for @code{ivy-read}::
* Optional arguments for @code{ivy-read}::
* Example - @code{counsel-describe-function}::
* Example - @code{counsel-locate}::
@end detailmenu
@end menu
@node Introduction
@chapter Introduction
Ivy is for quick and easy selection from a list. When Emacs prompts
for a string from a list of several possible choices, Ivy springs into
action to assist in narrowing and picking the right string from a vast
number of choices.
Ivy strives for minimalism, simplicity, customizability and
discoverability.
@subsubheading Minimalism
@indentedblock
Uncluttered minibuffer is minimalism. Ivy shows the completion
defaults, the number of matches, and 10 candidate matches below
the input line. Customize @code{ivy-height} to adjust the number of
candidate matches displayed in the minibuffer.
@end indentedblock
@subsubheading Simplicity
@indentedblock
Simplicity is about Ivy's behavior in the minibuffer. It is also
about the code interface to extend Ivy's functionality. The
minibuffer area behaves as close to @code{fundamental-mode} as
possible. @kbd{SPC} inserts a space, for example, instead of being
bound to the more complex @code{minibuffer-complete-word}. Ivy's code
uses easy-to-examine global variables; avoids needless
complications with branch-introducing custom macros.
@end indentedblock
@subsubheading Customizability
@indentedblock
Customizability is about being able to use different methods and
interfaces of completion to tailor the selection process. For
example, adding a custom display function that points to a
selected candidate with @code{>}, instead of highlighting the selected
candidate with the @code{ivy-current-match} face (see
@code{ivy-format-function}). Or take the customization of actions, say
after the candidate function is selected. @kbd{RET} uses
@code{counsel-describe-function} to describe the function, whereas
@kbd{M-o d} jumps to that function's definition in the code. The
@kbd{M-o} prefix can be uniformly used with characters like @kbd{d} to
group similar actions.
@end indentedblock
@subsubheading Discoverability
@indentedblock
Ivy displays easily discoverable commands through the hydra
facility. @kbd{C-o} in the minibuffer displays a hydra menu. It
opens up within an expanded minibuffer area. Each menu item comes
with short documentation strings and highlighted one-key
completions. So discovering even seldom used keys is simply a
matter of @kbd{C-o} in the minibuffer while in the midst of the Ivy
interaction. This discoverability minimizes exiting Ivy interface
for documentation look-ups.
@end indentedblock
@node Installation
@chapter Installation
Install Ivy automatically through Emacs's package manager, or manually
from Ivy's development repository.
Emacs 24.3.1 is the oldest version to run Ivy. Emacs 24.5.1 is the
oldest version that runs Ivy with fancy faces display.
@menu
* Installing from Emacs Package Manager::
* Installing from the Git repository::
@end menu
@node Installing from Emacs Package Manager
@section Installing from Emacs Package Manager
@kbd{M-x} @code{package-install} @kbd{RET} @code{swiper} @kbd{RET}
Ivy is installed as part of @code{swiper} package. @code{swiper} is available
from two different package archives, GNU ELPA and MELPA. For the
latest stable version, use the GNU ELPA archives using the above M-x
command.
For current hourly builds, use the MELPA archives. See the code below
for adding MELPA to the list of package archives:
@lisp
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.org/packages/"))
@end lisp
After this do @kbd{M-x} @code{package-refresh-contents} @kbd{RET}, followed by
@kbd{M-x} @code{package-install} @kbd{RET} @code{counsel} @kbd{RET}.
For package manager details, see @ref{Packages,,,emacs,}.
@node Installing from the Git repository
@section Installing from the Git repository
@subsubheading Why install from Git?
@indentedblock
@itemize
@item
No need to wait for MELPA's hourly builds
@item
Easy to revert to previous versions
@item
Contribute to Ivy's development; send patches; pull requests
@end itemize
@end indentedblock
@subsubheading Configuration steps
@indentedblock
First clone the Swiper repository with:
@example
cd ~/git && git clone https://github.com/abo-abo/swiper
cd swiper && make compile
@end example
Second, add these lines to the Emacs init file:
@lisp
(add-to-list 'load-path "~/git/swiper/")
(require 'ivy)
@end lisp
Then, update the code with:
@example
git pull
make
@end example
@end indentedblock
@node Getting started
@chapter Getting started
First enable Ivy completion everywhere:
@lisp
(ivy-mode 1)
@end lisp
Note: @code{ivy-mode} can be toggled on and off with @kbd{M-x} @code{ivy-mode}.
@menu
* Basic customization::
@end menu
@node Basic customization
@section Basic customization
Here are some basic settings particularly useful for new Ivy users:
@lisp
(setq ivy-use-virtual-buffers t)
(setq ivy-count-format "(%d/%d) ")
@end lisp
If you want, you can go without any customizations at all. The above
settings are the most bang for the buck in terms of customization. So
users that typically don't like customize a lot are advised to look at
these settings first.
For more advanced customizations, refer to @code{M-x describe-variable}
documentation.
@node Key bindings
@chapter Key bindings
@menu
* Global key bindings::
* Minibuffer key bindings::
@end menu
@node Global key bindings
@section Global key bindings
The recommended key bindings are:
@subsubheading Ivy-based interface to standard commands
@indentedblock
@lisp
(global-set-key (kbd "C-s") 'swiper)
(global-set-key (kbd "M-x") 'counsel-M-x)
(global-set-key (kbd "C-x C-f") 'counsel-find-file)
(global-set-key (kbd "<f1> f") 'counsel-describe-function)
(global-set-key (kbd "<f1> v") 'counsel-describe-variable)
(global-set-key (kbd "<f1> l") 'counsel-load-library)
(global-set-key (kbd "<f2> i") 'counsel-info-lookup-symbol)
(global-set-key (kbd "<f2> u") 'counsel-unicode-char)
@end lisp
@end indentedblock
@subsubheading Ivy-based interface to shell and system tools
@indentedblock
@lisp
(global-set-key (kbd "C-c g") 'counsel-git)
(global-set-key (kbd "C-c j") 'counsel-git-grep)
(global-set-key (kbd "C-c k") 'counsel-ag)
(global-set-key (kbd "C-x l") 'counsel-locate)
(global-set-key (kbd "C-S-o") 'counsel-rhythmbox)
@end lisp
@end indentedblock
@subsubheading Ivy-resume and other commands
@indentedblock
@code{ivy-resume} resumes the last Ivy-based completion.
@lisp
(global-set-key (kbd "C-c C-r") 'ivy-resume)
@end lisp
@end indentedblock
@node Minibuffer key bindings
@section Minibuffer key bindings
@vindex ivy-minibuffer-map
Ivy includes several minibuffer bindings, which are defined in the
@code{ivy-minibuffer-map} keymap variable. The most frequently used ones
are described here.
@code{swiper} or @code{counsel-M-x} add more key bindings through the @code{keymap}
argument to @code{ivy-read}. These keys, also active in the minibuffer, are
described under their respective commands.
A key feature of @code{ivy-minibuffer-map} is its full editing capability
where the familiar @kbd{C-a}, @kbd{C-f}, @kbd{M-d}, @kbd{M-DEL}, @kbd{M-b}, @kbd{M-w}, @kbd{C-k},
@kbd{C-y} key bindings work the same as in @code{fundamental-mode}.
@menu
* Key bindings for navigation::
* Key bindings for single selection, action, then exit minibuffer: Key bindings for single selection action then exit minibuffer.
* Key bindings for multiple selections and actions, keep minibuffer open: Key bindings for multiple selections and actions keep minibuffer open.
* Key bindings that alter the minibuffer input::
* Other key bindings::
* Hydra in the minibuffer::
* Saving the current completion session to a buffer::
@end menu
@node Key bindings for navigation
@subsection Key bindings for navigation
@itemize
@item
@kbd{C-n} (@code{ivy-next-line}) selects the next candidate
@item
@kbd{C-p} (@code{ivy-previous-line}) selects the previous candidate
@item
@kbd{M-<} (@code{ivy-beginning-of-buffer}) selects the first candidate
@item
@kbd{M->} (@code{ivy-end-of-buffer}) selects the last candidate
@item
@kbd{C-v} (@code{ivy-scroll-up-command}) scrolls up by @code{ivy-height} lines
@item
@kbd{M-v} (@code{ivy-scroll-down-command}) scrolls down by @code{ivy-height} lines
@end itemize
@defopt ivy-wrap
Specifies the wrap-around behavior for @kbd{C-n} and @kbd{C-p}. When
@code{ivy-wrap} is set to @code{t}, @code{ivy-next-line} and @code{ivy-previous-line}
will cycle past the last and the first candidates respectively.
Warp-around behavior is off by default.
@end defopt
@defopt ivy-height
Use this option to adjust the minibuffer height, which also
affects scroll size when using @kbd{C-v} and @kbd{M-v} key bindings.
@code{ivy-height} is 10 lines by default.
@end defopt
@node Key bindings for single selection action then exit minibuffer
@subsection Key bindings for single selection, action, then exit minibuffer
Ivy can offer several actions from which to choose which action to
run. This "calling an action" operates on the selected candidate. For
example, when viewing a list of files, one action could open it for
editing, one to view it, another to invoke a special function, and so
on. Custom actions can be added to this interface. The precise action
to call on the selected candidate can be delayed until after the
narrowing is completed. No need to exit the interface if unsure which
action to run. This delayed flexibility and customization of actions
extends usability of lists in Emacs.
@subsubheading @kbd{C-m} or @kbd{RET} (@code{ivy-done})
@vindex ivy-done
@kindex C-m
@kindex RET
@indentedblock
Calls the default action and then exits the minibuffer.
@end indentedblock
@subsubheading @kbd{M-o} (@code{ivy-dispatching-done})
@vindex ivy-dispatching-done
@kindex M-o
@indentedblock
Presents valid actions from which to choose. When only one action
is available, there is no difference between @kbd{M-o} and @kbd{C-m}.
@end indentedblock
@subsubheading @kbd{C-j} (@code{ivy-alt-done})
@vindex ivy-alt-done
@kindex C-j
@indentedblock
When completing file names, selects the current directory
candidate and starts a new completion session there. Otherwise,
it is the same as @code{ivy-done}.
@end indentedblock
@subsubheading @kbd{TAB} (@code{ivy-partial-or-done})
@vindex ivy-partial-or-done
@kindex TAB
@indentedblock
Attempts partial completion, extending current input as much as
possible. @kbd{TAB TAB} is the same as @kbd{C-j} (@code{ivy-alt-done}).
Example ERT test:
@lisp
(should
(equal (ivy-with
'(progn
(ivy-read "Test: " '("can do" "can't, sorry" "other"))
ivy-text)
"c <tab>")
"can"))
@end lisp
@end indentedblock
@subsubheading @kbd{C-M-j} (@code{ivy-immediate-done})
@vindex ivy-immediate-done
@kindex C-M-j
@indentedblock
Exits with @emph{the current input} instead of @emph{the current candidate}
(like other commands).
This is useful e.g. when you call @code{find-file} to create a new
file, but the desired name matches an existing file. In that
case, using @kbd{C-j} would select that existing file, which isn't
what you want - use this command instead.
@end indentedblock
@subsubheading @kbd{C-'} (@code{ivy-avy})
@vindex ivy-avy
@kindex C-'
@indentedblock
Uses avy to select one of the candidates on the current candidate
page. This can often be faster than multiple @kbd{C-n} or @kbd{C-p}
keystrokes followed by @kbd{C-m}.
@end indentedblock
@node Key bindings for multiple selections and actions keep minibuffer open
@subsection Key bindings for multiple selections and actions, keep minibuffer open
For repeatedly applying multiple actions or acting on multiple
candidates, Ivy does not close the minibuffer between commands. It
keeps the minibuffer open for applying subsequent actions.
Adding an extra meta key to the normal key chord invokes the special
version of the regular commands that enables applying multiple
actions.
@subsubheading @kbd{C-M-m} (@code{ivy-call})
@vindex ivy-call
@kindex C-M-m
@indentedblock
Is the non-exiting version of @kbd{C-m} (@code{ivy-done}).
Instead of closing the minibuffer, @kbd{C-M-m} allows selecting
another candidate or another action. For example, @kbd{C-M-m} on
functions list invokes @code{describe-function}. When combined with
@kbd{C-n}, function descriptions can be invoked quickly in
succession.
@end indentedblock
@subsubheading @kbd{C-M-o} (@code{ivy-dispatching-call})
@vindex ivy-dispatching-call
@kindex C-M-o
@indentedblock
Is the non-exiting version of @kbd{M-o} (@code{ivy-dispatching-done}).
For example, during the @code{counsel-rhythmbox} completion, press
@kbd{C-M-o e} to en-queue the selected candidate, followed by @kbd{C-n
C-m} to play the next candidate - the current action reverts to
the default one after @kbd{C-M-o}.
@end indentedblock
@subsubheading @kbd{C-M-n} (@code{ivy-next-line-and-call})
@vindex ivy-next-line-and-call
@kindex C-M-n
@indentedblock
Combines @kbd{C-n} and @kbd{C-M-m}. Applies an action and moves to next
line.
Comes in handy when opening multiple files from
@code{counsel-find-file}, @code{counsel-git-grep}, @code{counsel-ag}, or
@code{counsel-locate} lists. Just hold @kbd{C-M-n} for rapid-fire default
action on each successive element of the list.
@end indentedblock
@subsubheading @kbd{C-M-p} (@code{ivy-previous-line-and-call})
@vindex ivy-previous-line-and-call
@kindex C-M-p
@indentedblock
Combines @kbd{C-p} and @kbd{C-M-m}.
Similar to the above except it moves through the list in the
other direction.
@end indentedblock
@subsubheading @code{ivy-resume}
@vindex ivy-resume
@indentedblock
Recalls the state of the completion session just before its last
exit.
Useful after an accidental @kbd{C-m} (@code{ivy-done}).
@end indentedblock
@node Key bindings that alter the minibuffer input
@subsection Key bindings that alter the minibuffer input
@subsubheading @kbd{M-n} (@code{ivy-next-history-element})
@vindex ivy-next-history-element
@kindex M-n
@indentedblock
Cycles forward through the Ivy command history.
Ivy updates an internal history list after each action. When this
history list is empty, @kbd{M-n} inserts symbol (or URL) at point
into the minibuffer.
@end indentedblock
@subsubheading @kbd{M-p} (@code{ivy-previous-history-element})
@vindex ivy-previous-history-element
@kindex M-p
@indentedblock
Cycles forward through the Ivy command history.
@end indentedblock
@subsubheading @kbd{M-i} (@code{ivy-insert-current})
@vindex ivy-insert-current
@kindex M-i
@indentedblock
Inserts the current candidate into the minibuffer.
Useful for copying and renaming files, for example: @kbd{M-i} to
insert the original file name string, edit it, and then @kbd{C-m} to
complete the renaming.
@end indentedblock
@subsubheading @kbd{M-j} (@code{ivy-yank-word})
@vindex ivy-yank-word
@kindex M-j
@indentedblock
Inserts the sub-word at point into the minibuffer.
This is similar to @kbd{C-s C-w} with @code{isearch}. Ivy reserves @kbd{C-w}
for @code{kill-region}.
@end indentedblock
@subsubheading @kbd{S-SPC} (@code{ivy-restrict-to-matches})
@vindex ivy-restrict-to-matches
@kindex S-SPC
@indentedblock
Deletes the current input, and resets the candidates list to the
currently restricted matches.
This is how Ivy provides narrowing in successive tiers.
@end indentedblock
@subsubheading @kbd{C-r} (@code{ivy-reverse-i-search})
@vindex ivy-reverse-i-search
@kindex C-r
@indentedblock
Starts a recursive completion session through the command's
history.
This works just like @kbd{C-r} at the bash command prompt, where the
completion candidates are the history items. Upon completion, the
selected candidate string is inserted into the minibuffer.
@end indentedblock
@node Other key bindings
@subsection Other key bindings
@subsubheading @kbd{M-w} (@code{ivy-kill-ring-save})
@vindex ivy-kill-ring-save
@kindex M-w
@indentedblock
Copies selected candidates to the kill ring.
Copies the region if the region is active.
@end indentedblock
@node Hydra in the minibuffer
@subsection Hydra in the minibuffer
@subsubheading @kbd{C-o} (@code{hydra-ivy/body})
@kindex C-o
@indentedblock
Invokes the hydra menu with short key bindings.
@end indentedblock
When Hydra is active, minibuffer editing is disabled and menus
display short aliases:
@multitable {aaaaa} {aaaaaaaaa} {aaaaaaaaaaaaaaaaaaaaaaaaa}
@headitem Short
@tab Normal
@tab Command name
@item @kbd{o}
@tab @kbd{C-g}
@tab @code{keyboard-escape-quit}
@item @kbd{j}
@tab @kbd{C-n}
@tab @code{ivy-next-line}
@item @kbd{k}
@tab @kbd{C-p}
@tab @code{ivy-previous-line}
@item @kbd{h}
@tab @kbd{M-<}
@tab @code{ivy-beginning-of-buffer}
@item @kbd{l}
@tab @kbd{M->}
@tab @code{ivy-end-of-buffer}
@item @kbd{d}
@tab @kbd{C-m}
@tab @code{ivy-done}
@item @kbd{f}
@tab @kbd{C-j}
@tab @code{ivy-alt-done}
@item @kbd{g}
@tab @kbd{C-M-m}
@tab @code{ivy-call}
@item @kbd{u}
@tab @kbd{C-c C-o}
@tab @code{ivy-occur}
@end multitable
Hydra reduces key strokes, for example: @kbd{C-n C-n C-n C-n} is @kbd{C-o
jjjj} in Hydra.
Hydra menu offers these additioanl bindings:
@subsubheading @kbd{c} (@code{ivy-toggle-calling})
@vindex ivy-toggle-calling
@kindex c
@indentedblock
Toggle calling the action after each candidate change. It
modifies @kbd{j} to @kbd{jg}, @kbd{k} to @kbd{kg} etc.
@end indentedblock
@subsubheading @kbd{m} (@code{ivy-toggle-fuzzy})
@vindex ivy-toggle-fuzzy
@kindex m
@indentedblock
Toggle the current regexp matcher.
@end indentedblock
@subsubheading @kbd{>} (@code{ivy-minibuffer-grow})
@vindex ivy-minibuffer-grow
@kindex >
@indentedblock
Increase @code{ivy-height} for the current minibuffer.
@end indentedblock
@subsubheading @kbd{<} (@code{ivy-minibuffer-shrink})
@vindex ivy-minibuffer-shrink
@kindex <
@indentedblock
Decrease @code{ivy-height} for the current minibuffer.
@end indentedblock
@subsubheading @kbd{w} (@code{ivy-prev-action})
@vindex ivy-prev-action
@kindex w
@indentedblock
Select the previous action.
@end indentedblock
@subsubheading @kbd{s} (@code{ivy-next-action})
@vindex ivy-next-action
@kindex s
@indentedblock
Select the next action.
@end indentedblock
@subsubheading @kbd{a} (@code{ivy-read-action})
@vindex ivy-read-action
@kindex a
@indentedblock
Use a menu to select an action.
@end indentedblock
@subsubheading @kbd{C} (@code{ivy-toggle-case-fold})
@vindex ivy-toggle-case-fold
@kindex C
@indentedblock
Toggle case folding (match both upper and lower case
characters for lower case input).
@end indentedblock
@node Saving the current completion session to a buffer
@subsection Saving the current completion session to a buffer
@subsubheading @kbd{C-c C-o} (@code{ivy-occur})
@vindex ivy-occur
@kindex C-c C-o
@indentedblock
Saves the current candidates to a new buffer and exits
completion.
@end indentedblock
The new buffer is read-only and has a few useful bindings defined.
@subsubheading @kbd{RET} or @kbd{j} (@code{ivy-occur-press})
@vindex ivy-occur-press
@kindex RET
@kindex j
@indentedblock
Call the current action on the selected candidate.
@end indentedblock
@subsubheading @kbd{mouse-1} (@code{ivy-occur-click})
@vindex ivy-occur-click
@kindex mouse-1
@indentedblock
Call the current action on the selected candidate.
@end indentedblock
@subsubheading @kbd{j} (@code{next-line})
@kindex j
@indentedblock
Move to next line.
@end indentedblock
@subsubheading @kbd{k} (@code{previous-line})
@kindex k
@indentedblock
Move to previous line.
@end indentedblock
@subsubheading @kbd{a} (@code{ivy-occur-read-action})
@vindex ivy-occur-read-action
@kindex a
@indentedblock
Read an action and make it current for this buffer.
@end indentedblock
@subsubheading @kbd{o} (@code{ivy-occur-dispatch})
@vindex ivy-occur-dispatch
@kindex o
@indentedblock
Read an action and call it on the selected candidate.
@end indentedblock
@subsubheading @kbd{q} (@code{quit-window})
@kindex q
@indentedblock
Bury the current buffer.
@end indentedblock
Ivy has no limit on the number of active buffers like these.
Ivy takes care of naming buffers uniquely by constructing descriptive
names. For example: @code{*ivy-occur counsel-describe-variable
"function$*}.
@node Completion Styles
@chapter Completion Styles
Ivy's completion functions rely on a regex builder - a function that
transforms a string input to a string regex. All current candidates
simply have to match this regex. Each collection can be assigned its
own regex builder by customizing @code{ivy-re-builders-alist}.
The keys of this alist are collection names, and the values are one of
the following:
@itemize
@item
@code{ivy--regex}
@item
@code{ivy--regex-plus}
@item
@code{ivy--regex-ignore-order}
@item
@code{ivy--regex-fuzzy}
@item
@code{regexp-quote}
@end itemize
A catch-all key, @code{t}, applies to all collections that don't have their
own key.
The default is:
@lisp
(setq ivy-re-builders-alist
'((t . ivy--regex-plus)))
@end lisp
This example shows a custom regex builder assigned to file name
completion:
@lisp
(setq ivy-re-builders-alist
'((read-file-name-internal . ivy--regex-fuzzy)
(t . ivy--regex-plus)))
@end lisp
Here, @code{read-file-name-internal} is a function that is passed as the
second argument to @code{completing-read} for file name completion.
The regex builder resolves as follows (in order of priority):
@enumerate
@item
@code{re-builder} argument passed to @code{ivy-read}.
@item
@code{collection} argument passed to @code{ivy-read} is a function and has an
entry on @code{ivy-re-builders-alist}.
@item
@code{caller} argument passed to @code{ivy-read} has an entry on
@code{ivy-re-builders-alist}.
@item
@code{this-command} has an entry on @code{ivy-re-builders-alist}.
@item
@code{t} has an entry on @code{ivy-re-builders-alist}.
@item
@code{ivy--regex}.
@end enumerate
@menu
* ivy--regex-plus::
* ivy--regex-ignore-order::
* ivy--regex-fuzzy::
@end menu
@node ivy--regex-plus
@section ivy--regex-plus
@code{ivy--regex-plus} is Ivy's default completion method.
@code{ivy--regex-plus} matches by splitting the input by spaces and
rebuilding it into a regex.
As the search string is typed in Ivy's minibuffer, it is transformed
into valid regex syntax. If the string is @code{"for example"}, it is
transformed into
@lisp
"\\(for\\).*\\(example\\)"
@end lisp
which in regex terminology matches @code{"for"} followed by a wild card and
then @code{"example"}. Note how Ivy uses the space character to build wild
cards. To match a literal white space, use an extra space. So to match
one space type two spaces, to match two spaces type three spaces, and
so on.
As Ivy transforms typed characters into regex strings, it provides an
intuitive feedback through font highlights.
Ivy supports regexp negation with @code{"!"}.
For example, @code{"define key ! ivy quit"} first selects everything
matching @code{"define.*key"}, then removes everything matching @code{"ivy"},
and finally removes everything matching @code{"quit"}. What remains is the
final result set of the negation regexp.
Since Ivy treats minibuffer input as a regexp, the standard regexp
identifiers work: @code{"^"}, @code{"$"}, @code{"\b"} or @code{"[a-z]"}. The exceptions
are spaces, which translate to @code{".*"}, and @code{"!"} that signal the
beginning of a negation group.
@node ivy--regex-ignore-order
@section ivy--regex-ignore-order
@code{ivy--regex-ignore-order} ignores the order of regexp tokens when
searching for matching candidates. For instance, the input
@code{"for example"} will match @code{"example test for"}.
@node ivy--regex-fuzzy
@section ivy--regex-fuzzy
@code{ivy--regex-fuzzy} splits each character with a wild card. Searching
for @code{"for"} returns all @code{"f.*o.*r"} matches, resulting in a large
number of hits. Yet some searches need these extra hits. Ivy sorts
such large lists using @code{flx} package's scoring mechanism, if it's
installed.
@kbd{C-o m} toggles the current regexp builder.
@node Customization
@chapter Customization
@menu
* Faces::
* Defcustoms::
* Actions::
* Packages::
@end menu
@node Faces
@section Faces
@subsubheading @code{ivy-current-match}
@vindex ivy-current-match
@indentedblock
Highlights the currently selected candidate.
@end indentedblock
@subsubheading @code{ivy-minibuffer-match-face-1}
@vindex ivy-minibuffer-match-face-1
@indentedblock
Highlights the background of the match.
@end indentedblock
@subsubheading @code{ivy-minibuffer-match-face-2}
@vindex ivy-minibuffer-match-face-2
@indentedblock
Highlights the first (modulo 3) matched group.
@end indentedblock
@subsubheading @code{ivy-minibuffer-match-face-3}
@vindex ivy-minibuffer-match-face-3
@indentedblock
Highlights the second (modulo 3) matched group.
@end indentedblock
@subsubheading @code{ivy-minibuffer-match-face-4}
@vindex ivy-minibuffer-match-face-4
@indentedblock
Highlights the third (modulo 3) matched group.
@end indentedblock
@subsubheading @code{ivy-confirm-face}
@vindex ivy-confirm-face
@indentedblock
Highlights the "(confirm)" part of the prompt.
When @code{confirm-nonexistent-file-or-buffer} set to @code{t}, then
confirming non-existent files in @code{ivy-mode} requires an
additional @kbd{RET}.
The confirmation prompt will use this face.
For example:
@lisp
(setq confirm-nonexistent-file-or-buffer t)
@end lisp
Then call @code{find-file}, enter "eldorado" and press @kbd{RET} - the
prompt will be appended with "(confirm)". Press @kbd{RET} once more
to confirm, or any key to continue the completion.
@end indentedblock
@subsubheading @code{ivy-match-required-face}
@vindex ivy-match-required-face
@indentedblock
Highlights the "(match required)" part of the prompt.
When completions have to match available candidates and cannot
take random input, the "(match required)" prompt signals this
constraint.
For example, call @code{describe-variable}, enter "waldo" and press
@kbd{RET} - "(match required)" is prompted.
Press any key for the prompt to disappear.
@end indentedblock
@subsubheading @code{ivy-subdir}
@vindex ivy-subdir
@indentedblock
Highlights directories when completing file names.