forked from emacs-helm/helm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
helm-help.el
2394 lines (1734 loc) · 90.3 KB
/
helm-help.el
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
;;; helm-help.el --- Help messages for Helm. -*- lexical-binding: t -*-
;; Copyright (C) 2012 ~ 2020 Thierry Volpiatto <thierry.volpiatto@gmail.com>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
(require 'helm)
(defgroup helm-help nil
"Embedded help for `helm'."
:group 'helm)
(defface helm-helper
`((t ,@(and (>= emacs-major-version 27) '(:extend t))
:inherit helm-header))
"Face for Helm help string in minibuffer."
:group 'helm-help)
(defvar helm-help--string-list '(helm-help-message
helm-buffer-help-message
helm-ff-help-message
helm-read-file-name-help-message
helm-generic-file-help-message
helm-fd-help-message
helm-grep-help-message
helm-pdfgrep-help-message
helm-etags-help-message
helm-ucs-help-message
helm-bookmark-help-message
helm-esh-help-message
helm-buffers-ido-virtual-help-message
helm-moccur-help-message
helm-top-help-message
helm-el-package-help-message
helm-M-x-help-message
helm-imenu-help-message
helm-colors-help-message
helm-semantic-help-message
helm-kmacro-help-message
helm-kill-ring-help-message)
"A list of help messages (strings) used by `helm-documentation'.")
(defvar helm-documentation-buffer-name "*helm documentation*")
;;;###autoload
(defun helm-documentation ()
"Preconfigured `helm' for Helm documentation.
With a prefix arg refresh the documentation.
Find here the documentation of all documented sources."
(interactive)
(let ((buf (get-buffer-create helm-documentation-buffer-name)))
(switch-to-buffer buf)
(set-buffer buf)
(let ((inhibit-read-only t))
(erase-buffer)
(save-excursion
(cl-loop for elm in helm-help--string-list
for str = (helm-interpret-value elm)
do (insert (substitute-command-keys str) "\n\n")))
(org-mode))
(setq buffer-read-only t)
(view-mode)))
;;; Local help messages.
;;; `helm-buffer-list' help
;;
;;
(defvar helm-buffer-help-message
"* Helm Buffer
** Tips
*** Completion
**** Major-mode
You can enter a partial major-mode name (e.g. lisp, sh) to narrow down buffers.
To specify the major-mode, prefix it with \"*\" e.g. \"*lisp\".
If you want to match all buffers but the ones with a specific major-mode
\(negation), prefix the major-mode with \"!\" e.g. \"*!lisp\".
If you want to specify more than one major-mode, separate them with \",\",
e.g. \"*!lisp,!sh,!fun\" lists all buffers but the ones in lisp-mode, sh-mode
and fundamental-mode.
Then enter a space followed by a pattern to narrow down to buffers matching this
pattern.
**** Search inside buffers
If you enter a space and a pattern prefixed by \"@\", Helm searches for text
matching this pattern *inside* the buffer (i.e. not in the name of the buffer).
Negation are supported i.e. \"!\".
When you specify more than one of such patterns, it will match
buffers with contents matching each of these patterns i.e. AND,
not OR. That means that if you specify \"@foo @bar\" the contents
of buffer will have to be matched by foo AND bar. If you specify
\"@foo @!bar\" it means the contents of the buffer have to be
matched by foo but NOT bar.
If you enter a pattern prefixed with an escaped \"@\", Helm searches for a
buffer matching \"@pattern\" but does not search inside the buffer.
**** Search by directory name
If you prefix the pattern with \"/\", Helm matches over the directory names
of the buffers.
This feature can be used to narrow down the search to one directory while
subsequent strings entered after a space match over the buffer name only.
Note that negation is not supported for matching on buffer filename.
Starting from Helm v1.6.8, you can specify more than one directory.
**** Fuzzy matching
`helm-buffers-fuzzy-matching' turns on fuzzy matching on buffer
names, but not on directory names or major modes. A pattern
starting with \"^\" disables fuzzy matching and matching is done
litteraly IOW do not use regexps (\"^\" or whatever special
regexp character) when you want to fuzzy match.
**** Examples
With the following pattern
\"*lisp ^helm @moc\"
Helm narrows down the list by selecting only the buffers that are in lisp mode,
start with \"helm\" and which content matches \"moc\".
Without the \"@\"
\"*lisp ^helm moc\"
Helm looks for lisp mode buffers starting with \"helm\" and containing \"moc\"
in their name.
With this other pattern
\"*!lisp !helm\"
Helm narrows down to buffers that are not in \"lisp\" mode and that do not match
\"helm\".
With this last pattern
/helm/ w3
Helm narrows down to buffers that are in any \"helm\" subdirectory and
matching \"w3\".
*** Creating buffers
When creating a new buffer, use `\\[universal-argument]' to choose a mode from a
list. This list is customizable, see `helm-buffers-favorite-modes'.
*** Killing buffers
You can kill buffers either one by one or all the marked buffers at once.
One kill-buffer command leaves Helm while the other is persistent. Run the
persistent kill-buffer command either with the regular
`helm-execute-persistent-action' called with a prefix argument (`\\[universal-argument] \\<helm-map>\\[helm-execute-persistent-action]')
or with its specific command `helm-buffer-run-kill-persistent'. See the
bindings below.
*** Switching to buffers
To switch to a buffer, press RET, to switch to a buffer in another window, select this buffer
and press \\<helm-buffer-map>\\[helm-buffer-switch-other-window], when called with a prefix arg
the buffer will be displayed vertically in other window.
If you mark more than one buffer, the marked buffers will be displayed in different windows.
*** Saving buffers
If buffer is associated to a file and is modified, it is by default colorized in orange,
see [[Meaning of colors and prefixes for buffers][Meaning of colors and prefixes for buffers]].
You can save these buffers with \\<helm-buffer-map>\\[helm-buffer-save-persistent].
If you want to save all these buffers, you can mark them with \\[helm-buffers-mark-similar-buffers]
and save them with \\[helm-buffer-save-persistent]. You can also do this in one step with
\\[helm-buffer-run-save-some-buffers]. Note that you will not be asked for confirmation.
*** Meaning of colors and prefixes for buffers
Remote buffers are prefixed with '@'.
Red => Buffer's file was modified on disk by an external process.
Indianred2 => Buffer exists but its file has been deleted.
Orange => Buffer is modified and not saved to disk.
Italic => A non-file buffer.
Yellow => Tramp archive buffer.
** Commands
\\<helm-buffer-map>
|Keys|Description|
|-------------+----------|
|\\[helm-buffer-run-zgrep]|Grep Buffer(s) works as zgrep too (`\\[universal-argument]' to grep all buffers but non-file buffers).
|\\[helm-buffers-run-occur]|Multi-Occur buffer or marked buffers (`\\[universal-argument]' to toggle force-searching current-buffer).
|\\[helm-buffer-switch-other-window]|Switch to other window.
|\\[helm-buffer-switch-other-frame]|Switch to other frame.
|\\[helm-buffers-run-browse-project]|Browse project from buffer.
|\\[helm-buffer-run-query-replace-regexp]|Query-replace-regexp in marked buffers.
|\\[helm-buffer-run-query-replace]|Query-replace in marked buffers.
|\\[helm-buffer-run-ediff]|Ediff current buffer with candidate. With two marked buffers, ediff those buffers.
|\\[helm-buffer-run-ediff-merge]|Ediff-merge current buffer with candidate. With two marked buffers, ediff-merge those buffers.
|\\[helm-buffer-diff-persistent]|Toggle Diff-buffer with saved file without leaving Helm.
|\\[helm-buffer-revert-persistent]|Revert buffer without leaving Helm.
|\\[helm-buffer-save-persistent]|Save buffer without leaving Helm.
|\\[helm-buffer-run-save-some-buffers]|Save all unsaved buffers.
|\\[helm-buffer-run-kill-buffers]|Delete marked buffers and leave Helm.
|\\[helm-buffer-run-kill-persistent]|Delete buffer without leaving Helm.
|\\[helm-buffer-run-rename-buffer]|Rename buffer.
|\\[helm-toggle-all-marks]|Toggle all marks.
|\\[helm-mark-all]|Mark all.
|\\[helm-toggle-buffers-details]|Toggle details.
|\\[helm-buffers-toggle-show-hidden-buffers]|Show hidden buffers.
|\\[helm-buffers-mark-similar-buffers]|Mark all buffers of the same type (color) as current buffer.")
;;; Find files help (`helm-find-files')
;;
;;
(defvar helm-ff-help-message
"* Helm Find Files
** Tips
*** Navigation summary
For a better experience you can enable auto completion by setting
`helm-ff-auto-update-initial-value' to non-nil in your init file. It is not
enabled by default to not confuse new users.
**** Navigate with arrow keys
You can use <right> and <left> arrows to go down or up one level, to disable
this customize `helm-ff-lynx-style-map'.
Note that using `setq' will NOT work.
**** Use `\\<helm-find-files-map>\\[helm-execute-persistent-action]' (persistent action) on a directory to go down one level
On a symlinked directory a prefix argument expands to its true name.
**** Use `\\<helm-find-files-map>\\[helm-find-files-up-one-level]' or `DEL' on a directory to go up one level
***** `DEL' behavior
`DEL' by default deletes char backward.
But when `helm-ff-DEL-up-one-level-maybe' is non nil `DEL' behaves
differently depending on the contents of helm-pattern. It goes up one
level if the pattern is a directory ending with \"/\" or disables HFF
auto update and delete char backward if the pattern is a filename or
refers to a non existing path. Going up one level can be disabled
if necessary by deleting \"/\" at the end of the pattern using
\\<helm-map>\\[backward-char] and \\[helm-delete-minibuffer-contents].
Note that when deleting char backward, Helm takes care of
disabling update giving you the opportunity to edit your pattern for
e.g. renaming a file or creating a new file or directory.
When `helm-ff-auto-update-initial-value' is non nil you may want to
disable it temporarily, see [[Toggle auto-completion][Toggle auto-completion]] for this.
**** Use `\\<helm-find-files-map>\\[helm-find-files-down-last-level]' to walk back the resulting tree of all the `\\<helm-find-files-map>\\[helm-find-files-up-one-level]' or DEL you did
The tree is reinitialized each time you browse a new tree with
`\\<helm-map>\\[helm-execute-persistent-action]' or by entering some pattern in the prompt.
**** `RET' behavior
It behaves differently depending on `helm-selection' (current candidate in helm-buffer):
- candidate basename is \".\" => Open it in dired.
- candidate is a directory => Expand it.
- candidate is a file => Open it.
If you have marked candidates and you press RET on a directory,
Helm will navigate to this directory. If you want to exit with
RET with default action with these marked candidates, press RET a
second time while you are on the root of this directory e.g.
\"/home/you/dir/.\" or press RET on any file which is not a
directory. You can also exit with default action at any moment
with `f1'.
Note that when copying, renaming, etc. from `helm-find-files' the
destination file is selected with `helm-read-file-name'.
**** `TAB' behavior
Normally `TAB' is bound to `helm-select-action' in helm-map which
display the action menu.
You can change this behavior by setting in `helm-find-files-map'
a new command for `TAB':
(define-key helm-find-files-map (kbd \"C-i\") 'helm-ff-TAB)
It will then behave slighly differently depending of
`helm-selection':
- candidate basename is \".\" => open the action menu.
- candidate is a directory => expand it (behave as \\<helm-map>\\[helm-execute-persistent-action]).
- candidate is a file => open action menu.
Called with a prefix arg open menu unconditionally.
*** Filter out files or directories
You can show files or directories only with respectively
\\<helm-find-files-map>\\[helm-ff-toggle-dirs-only] and \\<helm-find-files-map>\\[helm-ff-toggle-files-only].
These are toggle commands i.e. filter/show_all.
Changing directory disable filtering.
*** Sort directory contents
When listing a directory without narrowing its contents, i.e. when pattern ends with \"/\",
you can sort alphabetically, by newest or by size by using respectively
\\<helm-find-files-map>\\[helm-ff-sort-alpha], \\[helm-ff-sort-by-newest] or \\[helm-ff-sort-by-size].
NOTE:
When starting back narrowing i.e. entering something in minibuffer after \"/\" sorting is done
again with fuzzy sorting and no more with sorting methods previously selected.
*** Find file at point
Helm uses `ffap' partially or completely to find file at point depending on the
value of `helm-ff-guess-ffap-filenames': if non-nil, support is complete
\(annoying), if nil, support is partial.
Note that when the variable
`helm-ff-allow-non-existing-file-at-point' is non nil Helm will
insert the filename at point even if file with this name doesn't
exists. If non existing file at point ends with numbers prefixed
with \":\" the \":\" and numbers are stripped.
**** Find file at line number
When text at point is in the form of
~/elisp/helm/helm.el:1234
Helm finds this file at the indicated line number, here 1234.
**** Find URL at point
When a URL is found at point, Helm expands to that URL only.
Pressing `RET' opens that URL using `browse-url-browser-function'.
**** Find e-mail address at point
When an e-mail address is found at point, Helm expands to this e-mail address
prefixed with \"mailto:\". Pressing `RET' opens a message buffer with that
e-mail address.
*** Quick pattern expansion
**** Enter `~/' at end of pattern to quickly reach home directory
**** Enter `/' at end of pattern to quickly reach the file system root
**** Enter `./' at end of pattern to quickly reach `default-directory'
\(As per its value at the beginning of the session.)
If you already are in the `default-directory' this will move the cursor to the top.
**** Enter `../' at end of pattern will reach upper directory, moving cursor to the top
This is different from using `\\<helm-find-files-map>\\[helm-find-files-up-one-level]' in that it moves
the cursor to the top instead of remaining on the previous subdir name.
**** Enter `..name/' at end of pattern to start a recursive search
It searches directories matching \"name\" under the current directory, see the
\"Recursive completion on subdirectories\" section below for more details.
**** Any environment variable (e.g. `$HOME') at end of pattern gets expanded
**** Any valid filename yanked after pattern gets expanded
**** Special case: URL at point
The quick expansions do not take effect after end a URL, you must kill the
pattern first (`\\[helm-delete-minibuffer-contents]').
*** Helm-find-files supports fuzzy matching
It starts from the third character of the pattern.
For instance \"fob\" or \"fbr\" will complete \"foobar\" but \"fb\" needs a
third character in order to complete it.
*** `\\[helm-execute-persistent-action]' on a filename expands to that filename in the Helm buffer
Second hit displays the buffer filename.
Third hit kills the buffer filename.
Note: `\\[universal-argument] \\[helm-execute-persistent-action]' displays the buffer directly.
*** Browse images directories with `helm-follow-mode' and navigate up/down
Before Emacs-27 Helm was using image-dired that works with
external ImageMagick tools. From Emacs-27 Helm use native
display of images with image-mode by default for Emacs-27 (see `helm-ff-display-image-native'),
this allows automatic resize when changing window size, zooming with `\\[helm-ff-increase-image-size-persistent]' and `\\[helm-ff-decrease-image-size-persistent]'
and rotate images as before.
You can also use `helm-follow-action-forward' and `helm-follow-action-backward' with
`\\[helm-follow-action-forward]' and `\\[helm-follow-action-backward]' respectively.
Note that these commands have different behavior when `helm-follow-mode'
is enabled (go to next/previous line only).
Use `\\[universal-argument] \\[helm-execute-persistent-action]' to display an image or kill its buffer.
TIP: Use `\\<helm-map>\\[helm-toggle-resplit-and-swap-windows]' and `\\[helm-enlarge-window]' to display Helm window vertically
and to enlarge it while viewing images.
Note this may not work with exotic Helm windows settings such as the ones in Spacemacs.
*** Open files externally
- Open file with external program (`\\<helm-find-files-map>\\[helm-ff-run-open-file-externally]',`C-u' to choose).
Helm is looking what is used by default to open file
externally (mailcap files) but have its own variable
`helm-external-programs-associations' to store external
applications. If you call the action or its binding without
prefix arg Helm will see if there is an application suitable in
`helm-external-programs-associations', otherwise it will look in
mailcap files. If you want to specify which external application
to use (and its options) use a prefix arg.
Note: What you configure for Helm in `helm-external-programs-associations'
will take precedence on mailcap files.
- Preview file with external program (`\\[helm-ff-run-preview-file-externally]').
Same as above but doesn't quit Helm session, it is apersistent action.
- Open file externally with default tool (`\\[helm-ff-run-open-file-with-default-tool]').
This uses xdg-open which sucks most of the time, but perhaps it
works fine on Windows. This is why it is kept in Helm.
*** Toggle auto-completion
It is useful when trying to create a new file or directory and you don't want
Helm to complete what you are writing.
Note: On a terminal, the default binding `C-<backspace>' may not work.
In this case use `C-c <backspace>'.
*** You can create a new directory and a new file at the same time
Simply write the path in the prompt and press `RET', e.g.
\"~/new/newnew/newnewnew/my_newfile.txt\".
*** To create a new directory, append a \"/\" to the new name and press `RET'
*** To create a new file, enter a filename not ending with \"/\"
Note that when you enter a new name, this one is prefixed with
\[?] if you are in a writable directory. If you are in a directory
where you have no write permission the new file name is not
prefixed and is colored in red. There is not such distinction
when using Tramp, new filename just appears on top of buffer.
*** Recursive search from Helm-find-files
**** You can use Helm-browse-project (see binding below)
- With no prefix argument:
If the current directory is under version control with either git or hg and
helm-ls-git and/or helm-ls-hg are installed, it lists all the files under
version control. Otherwise it falls back to Helm-find-files. See
https://github.com/emacs-helm/helm-ls-git and
https://github.com/emacs-helm/helm-ls-hg.
- With one prefix argument:
List all the files under this directory and other subdirectories
\(recursion) and this list of files will be cached.
- With two prefix arguments:
Same but the cache is refreshed.
**** You can start a recursive search with \"locate\", \"find\" or [[https://github.com/sharkdp/fd][Fd]]
See \"Note\" in the [[Recursive completion on subdirectories][section on subdirectories]].
Using \"locate\", you can enable the local database with a prefix argument. If the
local database doesn't already exists, you will be prompted for its creation.
If it exists and you want to refresh it, give it two prefix args.
When using locate the Helm buffer remains empty until you type something.
Regardless Helm uses the basename of the pattern entered in the helm-find-files
session by default. Hitting `\\[next-history-element]' should just kick in the
locate search with this pattern. If you want Helm to automatically do this, add
`helm-source-locate' to `helm-sources-using-default-as-input'.
NOTE: On Windows use Everything with its command line ~es~ as a replacement of locate.
See [[https://github.com/emacs-helm/helm/wiki/Locate#windows][Locate on Windows]]
**** Recursive completion on subdirectories
Starting from the directory you are currently browsing, it is possible to have
completion of all directories underneath. Say you are at \"/home/you/foo/\" and
you want to go to \"/home/you/foo/bar/baz/somewhere/else\", simply type
\"/home/you/foo/..else\" and hit `\\[helm-execute-persistent-action]' or enter
the final \"/\". Helm will then list all possible directories under \"foo\"
matching \"else\".
Note: Completion on subdirectories uses \"locate\" as backend, you can configure
the command with `helm-locate-recursive-dirs-command'. Because this completion
uses an index, the directory tree displayed may be out-of-date and not reflect
the latest change until you update the index (using \"updatedb\" for \"locate\").
If for some reason you cannot use an index, the \"find\" command from
\"findutils\" can be used instead. It will be slower though. You need to pass
the basedir as first argument of \"find\" and the subdir as the value for
'-(i)regex' or '-(i)name' with the two format specs that are mandatory in
`helm-locate-recursive-dirs-command'.
Examples:
- \"find %s -type d -name '*%s*'\"
- \"find %s -type d -regex .*%s.*$\"
[[https://github.com/sharkdp/fd][Fd]] command is now also
supported which is regexp based and very fast. Here is the command
line to use:
- \"fd --hidden --type d .*%s.*$ %s\"
You can use also a glob based search, in this case use the --glob option:
- \"fd --hidden --type d --glob '*%s*' %s\"
*** Insert filename at point or complete filename at point
On insertion (not on completion, i.e. there is nothing at point):
- `\\[helm-ff-run-complete-fn-at-point]': insert absolute file name.
- `\\[universal-argument] \\[helm-ff-run-complete-fn-at-point]': insert abbreviated file name.
- `\\[universal-argument] \\[universal-argument] \\[helm-ff-run-complete-fn-at-point]': insert relative file name.
- `\\[universal-argument] \\[universal-argument] \\[universal-argument] \\[helm-ff-run-complete-fn-at-point]': insert basename.
On completion:
- Target starts with \"~/\": insert abbreviate file name.
- target starts with \"/\" or \"[a-z]:/\": insert full path.
- Otherwise: insert relative file name.
*** Use the wildcard to select multiple files
Use of wildcard is supported to run an action over a set of files.
Example: You can copy all the files with \".el\" extension by using \"*.el\" and
then run copy action.
Similarly, \"**.el\" (note the two stars) will recursively select all \".el\"
files under the current directory.
Note that when recursively copying files, you may have files with same name
dispatched across different subdirectories, so when copying them in the same
directory they will get overwritten. To avoid this Helm has a special action
called \"backup files\" that has the same behavior as the command line \"cp -f
--backup=numbered\": it allows you to copy many files with the same name from
different subdirectories into one directory. Files with same name are renamed
as follows: \"foo.txt.~1~\". Like with the --force option of cp, it is possible
to backup files in current directory.
This command is available only when `dired-async-mode' is active.
When using an action that involves an external backend (e.g. grep), using \"**\"
is not recommended (even thought it works fine) because it will be slower to
select all the files. You are better off leaving the backend to do it, it will
be faster. However, if you know you have not many files it is reasonable to use
this, also using not recursive wildcard (e.g. \"*.el\") is perfectly fine for
this.
The \"**\" feature is active by default in the option `helm-file-globstar'. It
is different from the Bash \"shopt globstar\" feature in that to list files with
a named extension recursively you would write \"**.el\" whereas in Bash it would
be \"**/*.el\". Directory selection with \"**/\" like Bash \"shopt globstar\"
option is not supported yet.
Helm supports different styles of wildcards:
- `sh' style, the ones supported by `file-expand-wildcards'.
e.g. \"*.el\", \"*.[ch]\" which match respectively all \".el\"
files or all \".c\" and \".h\" files.
- `bash' style (partially) In addition to what allowed in `sh'
style you can specify file extensions that have more than one
character like this: \"*.{sh,py}\" which match \".sh\" and
\".py\" files.
Of course in both styles you can specify one or two \"*\".
*** Query replace regexp on filenames
Replace different parts of a file basename with something else.
When calling this action you will be prompted twice as with
`query-replace', first for the matching expression of the text to
replace and second for the replacement text. Several facilities,
however, are provided to make the two prompts more powerfull.
**** Syntax of the first prompt
In addition to simple regexps, these shortcuts are available:
- Basename without extension => \"%.\"
- Only extension => \".%\"
- Substring => \"%:<from>:<to>\"
- Whole basename => \"%\"
**** Syntax of the second prompt
In addition to a simple string to use as replacement, here is what you can use:
- A placeholder refering to what you have selected in the first prompt: \"\\@\".
After this placeholder you can use a search-and-replace syntax à-la sed:
\"\\@/<regexp>/<replacement>/
You can select a substring from the string represented by the placeholder:
\"\\@:<from>:<to>\"
- A special character representing a number which is incremented: \"\\#\".
- Shortcuts for `upcase', `downcase' and `capitalize'
are available as`%u', `%d' and `%c' respectively.
**** Examples
***** Recursively rename all files with \".JPG\" extension to \".jpg\"
Use the `helm-file-globstar' feature described in [[Use the wildcard to select multiple files][recursive globbing]]
by entering \"**.JPG\" at the end of the Helm-find-files pattern, then hit
\\<helm-find-files-map>\\[helm-ff-run-query-replace-fnames-on-marked] and enter \"JPG\" on first prompt, then \"jpg\" on second prompt and hit `RET'.
Alternatively you can enter \".%\" at the first prompt, then \"jpg\" and hit
`RET'. Note that when using this instead of using \"JPG\" at the first prompt,
all extensions will be renamed to \"jpg\" even if the extension of one of the
files is, say, \"png\". If you want to keep the original extension you can use
\"%d\" at the second prompt (downcase).
***** Batch-rename files from number 001 to 00x
Use \"\\#\" inside the second prompt.
Example 1: To rename the files
foo.jpg
bar.jpg
baz.jpg
to
foo-001.jpg
foo-002.jpg
foo-003.jpg
use \"%.\" as matching regexp and \"foo-\\#\" as replacement string.
Example 2: To rename the files
foo.jpg
bar.jpg
baz.jpg
to
foo-001.jpg
bar-002.jpg
baz-003.jpg
use as matching regexp \"%.\" and as replacement string \"\\@-\\#\".
***** Replace a substring
Use \"%:<from>:<to>\".
Example: To rename files
foo.jpg
bar.jpg
baz.jpg
to
fOo.jpg
bAr.jpg
bAz.jpg
use as matching regexp \"%:1:2\" and as replacement string \"%u\" (upcase).
Note that you \*cannot* use \"%.\" and \".%\" along with substring replacement.
***** Modify the string from the placeholder (\\@)
- By substring, i.e. only using the substring of the placeholder: \"\\@:<from>:<to>\".
The length of placeholder is used for <to> when unspecified.
Example 1: \"\\@:0:2\" replaces from the beginning to the second char of the placeholder.
Example 2: \\@:2: replaces from the second char of the placeholder to the end.
- By search-and-replace: \"\\@/<regexp>/<replacement>/\".
Incremental replacement is also handled in <replacement>.
Example 3: \"\\@/foo/bar/\" replaces \"foo\" by \"bar\" in the placeholder.
Example 4: \"\\@/foo/-\\#/\" replaces \"foo\" in the placeholder by 001, 002, etc.
***** Clash in replacements (avoid overwriting files)
When performing any of these replacement operations you may end up with same
names as replacement. In such cases Helm numbers the file that would otherwise
overwritten. For instance, should you remove the \"-m<n>\" part from the files
\"emacs-m1.txt\", \"emacs-m2.txt\" and \"emacs-m3.txt\" you would end up with
three files named \"emacs.txt\", the second renaming overwriting first file, and
the third renaming overwriting second file and so on. Instead Helm will
automatically rename the second and third files as \"emacs(1).txt\" and
\"emacs(2).txt\" respectively.
***** Query-replace on filenames vs. serial-rename action
Unlike the [[Serial renaming][serial rename]] actions, the files renamed with
the query-replace action stay in their initial directory and are not moved to
the current directory. As such, using \"\\#\" to serial-rename files only makes
sense for files inside the same directory. It even keeps renaming files
with an incremental number in the next directories.
*** Serial renaming
You can use the serial-rename actions to rename, copy or symlink marked files to
a specific directory or in the current directory with all the files numbered
incrementally.
- Serial-rename by renaming:
Rename all marked files with incremental numbering to a specific directory.
- Serial-rename by copying:
Copy all marked files with incremental numbering to a specific directory.
- Serial-rename by symlinking:
Symlink all marked files with incremental numbering to a specific directory.
*** Edit marked files in a dired buffer
You can open a dired buffer containing only marked files with `\\<helm-find-files-map>\\[helm-ff-run-marked-files-in-dired]'.
With a prefix argument you can open this same dired buffer in wdired mode for
editing. Note that wildcards are supported as well, so you can use e.g.
\"*.txt\" to select all \".txt\" files in the current directory or \"**.txt\" to
select all files recursively from the current directory.
See [[Use the wildcard to select multiple files]] section above.
*** Defining default target directory for copying, renaming, etc
You can customize `helm-dwim-target' to behave differently depending on the
windows open in the current frame. Default is to provide completion on all
directories associated to each window.
*** Copying/Renaming from or to remote directories
Never use ssh tramp method to copy/rename large files, use
instead its scp method if you want to avoid out of memory
problems and crash Emacs or the whole system. Moreover when using
scp method, you will hit a bug when copying more than 3 files at
the time, see [[https://github.com/emacs-helm/helm/issues/1945][bug#1945]].
The best way actually is using Rsync to copy files from or to
remote, see [[Use Rsync to copy files][Use Rsync to copy files]].
Also if you often work on remote you may consider using SSHFS
instead of relying on tramp.
*** Copying and renaming asynchronously
If you have the async library installed (if you got Helm from MELPA you do), you
can use it for copying/renaming files by enabling `dired-async-mode'.
Note that even when async is enabled, running a copy/rename action with a prefix
argument will execute action synchronously. Moreover it will follow the first
file of the marked files in its destination directory.
When `dired-async-mode' is enabled, an additional action named \"Backup files\"
will be available. (Such command is not natively available in Emacs).
See [[Use the wildcard to select multiple files]] for details.
*** Use Rsync to copy files
If Rsync is available, you can use it to copy/sync files or directories
with some restrictions though:
- Copying from/to tramp sudo method may not work (permissions).
- Copying from remote to remote is not supported (rsync restriction)
however you can mount a remote with sshfs and copy to it (best), otherwise you have to modify
the command line with a prefix arg, see [[https://unix.stackexchange.com/questions/183504/how-to-rsync-files-between-two-remotes][how-to-rsync-files-between-two-remotes]]
for the command line to use.
This command is mostly useful when copying large files as it is
fast, asynchronous and provide a progress bar in mode-line. Each
rsync process have its own progress bar, so you can run several
rsync jobs, they are independents. If rsync fails you can
consult the \"*helm-rsync<n>*\" buffer to see rsync errors. An
help-echo (move mouse over progress bar) is provided to see which
file is in transfer. Note that when copying directories, no
trailing slashes are added to directory names, which mean that
directory is created on destination if it doesn't already exists,
see rsync documentation for more infos on rsync behavior. To
synchronize a directory, mark all in the directory and rsync all
marked to the destination directory or rsync the directory itself
to its parent, e.g. remote:/home/you/music => /home/you.
The options are configurable through `helm-rsync-switches', but
you can modify them on the fly when needed by using a prefix arg,
in this case you will be prompted for modifications.
NOTE: When selecting a remote file, if you use the tramp syntax
for specifying a port, i.e. host#2222, helm will add
automatically \"-e 'ssh -p 2222'\" to the rsync command line
unless you have specified yourself the \"-e\" option by editing
rsync command line with a prefix arg (see above).
*** Bookmark the `helm-find-files' session
You can bookmark the `helm-find-files' session with `\\[helm-ff-bookmark-set]'.
You can later retrieve these bookmarks by calling `helm-filtered-bookmarks'
or, from the current `helm-find-files' session, by hitting `\\[helm-find-files-switch-to-bookmark]'.
*** Grep files from `helm-find-files'
You can grep individual files from `helm-find-files' by using
\`\\<helm-find-files-map>\\[helm-ff-run-grep]'. This same command can also
recursively grep files from the current directory when called with a prefix
argument. In this case you will be prompted for the file extensions to use
\(grep backend) or the types of files to use (ack-grep backend). See the
`helm-grep-default-command' documentation to set this up. For compressed files
or archives, use zgrep with \`\\<helm-find-files-map>\\[helm-ff-run-zgrep]'.
Otherwise you can use recursive commands like \`\\<helm-find-files-map>\\[helm-ff-run-grep-ag]' or `\\<helm-find-files-map>\\[helm-ff-run-git-grep]'
that are much faster than using `\\<helm-find-files-map>\\[helm-ff-run-grep]' with a prefix argument.
See `helm-grep-ag-command' and `helm-grep-git-grep-command' to set this up.
You can also use \"id-utils\"' GID with \`\\<helm-find-files-map>\\[helm-ff-run-gid]'
by creating an ID index file with the \"mkid\" shell command.
All those grep commands use the symbol at point as the default pattern.
Note that default is different from input (nothing is added to the prompt until
you hit `\\[next-history-element]').
**** Grepping on remote files
On remote files grep is not well supported by TRAMP unless you suspend updates before
entering the pattern and re-enable it once your pattern is ready.
To toggle suspend-update, use `\\<helm-map>\\[helm-toggle-suspend-update]'.
*** Execute Eshell commands on files
Setting up aliases in Eshell allows you to set up powerful customized commands.
Your aliases for using eshell command on file should allow
specifying one or more files, use e.g. \"alias foo $1\" or
\"alias foo $*\", if you want your command to be asynchronous add
at end \"&\", e.g. \"alias foo $* &\".
Adding Eshell aliases to your `eshell-aliases-file' or using the
`alias' command from Eshell allows you to create personalized
commands not available in `helm-find-files' actions and use them
from `\\<helm-find-files-map>\\[helm-ff-run-eshell-command-on-file]'.
Example: You want a command to uncompress some \"*.tar.gz\" files from `helm-find-files':
1) Create an Eshell alias named, say, \"untargz\" with the command
\"alias untargz tar zxvf $*\".
2) Now from `helm-find-files' select the \"*.tar.gz\" file (you can also
mark files if needed) and hit `\\<helm-find-files-map>\\[helm-ff-run-eshell-command-on-file]'.
Note: When using marked files with this, the meaning of the prefix argument is
quite subtle. Say you have \"foo\", \"bar\" and \"baz\" marked; when you run
the alias command `example' on these files with no prefix argument it will run
`example' sequentially on each file:
$ example foo
$ example bar
$ example baz
With a prefix argument however it will apply `example' on all files at once:
$ example foo bar baz
Of course the alias command should support this.
If you add %s to the command line %s will be replaced with the candidate, this mean you can
add extra argument to your command e.g. command -extra-arg %s or command %s -extra-arg.
If you want to pass many files inside %s, don't forget to use a prefix arg.
You can also use special placeholders in extra-args,
see the specific info page once you hit `\\<helm-find-files-map>\\[helm-ff-run-eshell-command-on-file]'.
*** Using TRAMP with `helm-find-files' to read remote directories
`helm-find-files' works fine with TRAMP despite some limitations.
- Grepping files is not very well supported when used incrementally.
See [[Grepping on remote files]].
- Locate does not work on remote directories.
**** A TRAMP syntax crash course
Please refer to TRAMP's documentation for more details.
- Connect to host 192.168.0.4 as user \"foo\":
/scp:192.168.0.4@foo:
- Connect to host 192.168.0.4 as user \"foo\" on port 2222:
/scp:192.168.0.4@foo#2222:
- Connect to host 192.168.0.4 as root using multihops syntax:
/ssh:192.168.0.4@foo|sudo:192.168.0.4:
Note: You can also use `tramp-default-proxies-alist' when connecting often to
the same hosts.
As a rule of thumb, prefer the scp method unless using multihops (which only
works with the ssh method), especially when copying large files.
You need to hit `C-j' once on top of a directory on the first connection
to complete the pattern in the minibuffer.
**** Display color for directories, symlinks etc... with tramp
Starting at helm version 2.9.7 it is somewhat possible to
colorize fnames by listing files without loosing performances with
external commands (ls and awk) if your system is compatible.
For this you can use `helm-list-dir-external' as value
for `helm-list-directory-function'.
See `helm-list-directory-function' documentation for more infos.
**** Completing host
As soon as you enter the first \":\" after method e.g =/scp:= you will
have some completion about previously used hosts or from your =~/.ssh/config=
file, hitting `\\[helm-execute-persistent-action]' or `right' on a candidate will insert this host in minibuffer
without addind the ending \":\", second hit insert the last \":\".
As soon the last \":\" is entered TRAMP will kick in and you should see the list
of candidates soon after.
When connection fails, be sure to delete your TRAMP connection with M-x
`helm-delete-tramp-connection' before retrying.
**** Editing local files as root
Use the sudo method:
\"/sudo:host:\" or simply \"/sudo::\".
*** Attach files to a mail buffer (message-mode)
If you are in a `message-mode' or `mail-mode' buffer, that action will appear
in action menu, otherwise it is available at any time with \\<helm-find-files-map>\\[helm-ff-run-mail-attach-files].
It behaves as follows:
- If you are in a (mail or message) buffer, files are attached there.
- If you are not in a mail buffer but one or more mail buffers exist, you are
prompted to attach files to one of these mail buffers.
- If you are not in a mail buffer and no mail buffer exists,
a new mail buffer is created with the attached files in it.
*** Open files in separate windows
When [[Marked candidates][marking]] multiple files or using [[Use the wildcard to select multiple files][wildcard]], helm allow opening all
this files in separate windows using an horizontal layout or a