New key bindings scheme for searching
See commit content for documentation
This commit is contained in:
parent
fef908acad
commit
90008bb900
|
@ -102,10 +102,11 @@
|
||||||
- [[#docview-mode][DocView mode]]
|
- [[#docview-mode][DocView mode]]
|
||||||
- [[#searching][Searching]]
|
- [[#searching][Searching]]
|
||||||
- [[#with-an-external-tool][With an external tool]]
|
- [[#with-an-external-tool][With an external tool]]
|
||||||
|
- [[#useful-key-bindings][Useful key bindings]]
|
||||||
- [[#searching-in-current-file-][Searching in current file ]]
|
- [[#searching-in-current-file-][Searching in current file ]]
|
||||||
- [[#searching-in-all-open-buffers-visiting-files][Searching in all open buffers visiting files]]
|
- [[#searching-in-all-open-buffers-visiting-files][Searching in all open buffers visiting files]]
|
||||||
|
- [[#searching-for-files-in-an-arbitrary-directory][Searching for files in an arbitrary directory]]
|
||||||
- [[#searching-in-a-project][Searching in a project]]
|
- [[#searching-in-a-project][Searching in a project]]
|
||||||
- [[#searching-in-an-arbitrary-directory][Searching in an arbitrary directory]]
|
|
||||||
- [[#searching-the-web][Searching the web]]
|
- [[#searching-the-web][Searching the web]]
|
||||||
- [[#persistent-highlighting][Persistent highlighting]]
|
- [[#persistent-highlighting][Persistent highlighting]]
|
||||||
- [[#stacking-highlights][Stacking highlights]]
|
- [[#stacking-highlights][Stacking highlights]]
|
||||||
|
@ -1539,97 +1540,112 @@ OpenDocument, and Microsoft Office documents.
|
||||||
|
|
||||||
** Searching
|
** Searching
|
||||||
*** With an external tool
|
*** With an external tool
|
||||||
=Spacemacs= can be interfaced with different search utilities:
|
=Spacemacs= can be interfaced with different search utilities like:
|
||||||
- ack
|
- ack
|
||||||
- grep
|
- grep
|
||||||
- [[https://github.com/ggreer/the_silver_searcher][ag]]
|
- [[https://github.com/ggreer/the_silver_searcher][ag]]
|
||||||
- [[https://github.com/monochromegane/the_platinum_searcher][pt]]
|
- [[https://github.com/monochromegane/the_platinum_searcher][pt]]
|
||||||
|
|
||||||
*Note* =ag= and =pt= are optimized to be used in a source control repository but
|
The search commands in Spacemacs are organized under the ~SPC s~ prefix with
|
||||||
they can be used in an arbitrary directory as well.
|
the next key is the tool to use and the last key is the scope. For instance
|
||||||
|
~SPC s a b~ will search in all opened buffers using =ag=.
|
||||||
|
If the last key (determining the scope) is uppercase then the current region
|
||||||
|
or symbol under point is used as default input for the search. For instance
|
||||||
|
~SPC s a B~ will search with symbol under point (if there is no active region).
|
||||||
|
If the tool key is omitted then a default tool will be automatically
|
||||||
|
selected for the search. This tool corresponds to the first tool found on the
|
||||||
|
system of the list =dotspacemacs-search-tools=, the default order is =ag=,
|
||||||
|
=pt=, =ack= then =grep=. For instance ~SPC b b~ will search in the opened
|
||||||
|
buffers using =pt= if =ag= has not been found on the system.
|
||||||
|
|
||||||
|
The tool keys are:
|
||||||
|
|
||||||
|
| Tool | Key |
|
||||||
|
|------+-----|
|
||||||
|
| ag | a |
|
||||||
|
| grep | g |
|
||||||
|
| ack | k |
|
||||||
|
| pt | t |
|
||||||
|
|
||||||
|
The available scopes and corresponding keys are:
|
||||||
|
|
||||||
|
| Scope | Key |
|
||||||
|
|----------------------------+--------|
|
||||||
|
| opened buffers | b |
|
||||||
|
| files in a given directory | f |
|
||||||
|
| current project | p |
|
||||||
|
|
||||||
|
It is possible to search in the current file by double tapping the second key
|
||||||
|
of the sequence, for instance ~SPC s a a~ will search in the current
|
||||||
|
file with =ag=.
|
||||||
|
|
||||||
|
*Notes*
|
||||||
|
- =ag= and =pt= are optimized to be used in a source control repository but
|
||||||
|
they can be used in an arbitrary directory as well.
|
||||||
|
- It is also possible to search in several directories at once by marking
|
||||||
|
them in the helm buffer.
|
||||||
|
|
||||||
*Beware* if you use =pt=, [[https://core.tcl.tk/tcllib/doc/trunk/embedded/www/tcllib/files/apps/pt.html][TCL parser tools]] also install a command line tool
|
*Beware* if you use =pt=, [[https://core.tcl.tk/tcllib/doc/trunk/embedded/www/tcllib/files/apps/pt.html][TCL parser tools]] also install a command line tool
|
||||||
called =pt=.
|
called =pt=.
|
||||||
|
|
||||||
The search commands in Spacemacs are organized using the prefix of the command
|
**** Useful key bindings
|
||||||
according to the scope in which they operate. You can search in the current file
|
| Key Binding | Description |
|
||||||
(prefix ~SPC s~), in all current buffers corresponding to files (prefix ~SPC b
|
|-----------------+--------------------------------------------------------------------------|
|
||||||
s~), in all files in a project (prefix ~SPC p s~), or in arbitrary directories
|
| ~SPC h l~ | resume the last =helm= buffer |
|
||||||
(prefix ~SPC f s~). In each category, you can choose a tool explicitly or use
|
| ~F3~ | in a =helm= buffer, convert a =helm= search buffer into a regular buffer |
|
||||||
the smart version, which will look for the first installed tool in the list
|
| ~SPC s L~ | focus the last converted search buffer |
|
||||||
=("ag", "pt", "ack", "grep")=. This list can be changed in the dotfile with the
|
| Prefix argument | will ask for file extensions |
|
||||||
variable =dotspacemacs-search-tools=.
|
|
||||||
|
|
||||||
All of the key bindings are listed in the following sub-sections. Generally,
|
|
||||||
within each scope there are two key bindings corresponding to each external
|
|
||||||
tool. One inserts default text for the search pattern, while the other does not
|
|
||||||
insert the default text. The default text is the region selected when you call
|
|
||||||
the command. If no region is selected, the symbol underneath the point is used.
|
|
||||||
|
|
||||||
**** Searching in current file
|
**** Searching in current file
|
||||||
The key bindings available for searching the current file are
|
| Key Binding | Description |
|
||||||
| Key Binding | Description |
|
|-------------+-----------------------------------------------------|
|
||||||
|-------------+---------------------------------------------------------------------------|
|
| ~SPC s s~ | search with the first found tool |
|
||||||
| ~SPC s /~ | execute the first found utility (by default =ag=, =pt=, =ack= and =grep=) |
|
| ~SPC s S~ | search with the first found tool with default input |
|
||||||
| ~SPC s ?~ | same as above but use default text |
|
| ~SPC s a a~ | =ag= |
|
||||||
| ~SPC s a~ | =ag= |
|
| ~SPC s a A~ | =ag= with default input |
|
||||||
| ~SPC s A~ | =ag= with default text |
|
| ~SPC s g g~ | =grep= |
|
||||||
| ~SPC s g~ | =grep= |
|
| ~SPC s g G~ | =grep= with default input |
|
||||||
| ~SPC s G~ | =grep= with default text |
|
|
||||||
|
|
||||||
**** Searching in all open buffers visiting files
|
**** Searching in all open buffers visiting files
|
||||||
The key bindings available for searching all open buffers are
|
| Key Binding | Description |
|
||||||
| Key Binding | Description |
|
|-------------+-----------------------------------------------------|
|
||||||
|-------------+--------------------------|
|
| ~SPC s b~ | search with the first found tool |
|
||||||
| ~SPC b s a~ | =ag= |
|
| ~SPC s B~ | search with the first found tool with default input |
|
||||||
| ~SPC b s A~ | =ag= with default text |
|
| ~SPC s a b~ | =ag= |
|
||||||
| ~SPC b s g~ | =grep= |
|
| ~SPC s a B~ | =ag= with default text |
|
||||||
| ~SPC b s G~ | =grep= with default text |
|
| ~SPC s g b~ | =grep= |
|
||||||
| ~SPC b s k~ | =ack= |
|
| ~SPC s g B~ | =grep= with default text |
|
||||||
| ~SPC b s K~ | =ack= with default text |
|
| ~SPC s k b~ | =ack= |
|
||||||
| ~SPC b s p~ | =pt= |
|
| ~SPC s k B~ | =ack= with default text |
|
||||||
| ~SPC b s P~ | =pt= with default text |
|
| ~SPC s t b~ | =pt= |
|
||||||
|
| ~SPC s t B~ | =pt= with default text |
|
||||||
|
|
||||||
|
**** Searching for files in an arbitrary directory
|
||||||
|
| Key Binding | Description |
|
||||||
|
|-------------+-----------------------------------------------------|
|
||||||
|
| ~SPC s f~ | search with the first found tool |
|
||||||
|
| ~SPC s F~ | search with the first found tool with default input |
|
||||||
|
| ~SPC s a f~ | =ag= |
|
||||||
|
| ~SPC s a F~ | =ag= with default text |
|
||||||
|
| ~SPC s g f~ | =grep= |
|
||||||
|
| ~SPC s g F~ | =grep= with default text |
|
||||||
|
| ~SPC s k f~ | =ack= |
|
||||||
|
| ~SPC s k F~ | =ack= with default text |
|
||||||
|
| ~SPC s t f~ | =pt= |
|
||||||
|
| ~SPC s t F~ | =pt= with default text |
|
||||||
|
|
||||||
**** Searching in a project
|
**** Searching in a project
|
||||||
To use these utilities in a project using =projectile=:
|
| Key Binding | Description |
|
||||||
|
|-----------------------+-----------------------------------------------------|
|
||||||
| Key Binding | Description |
|
| ~SPC /~ or ~SPC s p~ | search with the first found tool |
|
||||||
|-------------+---------------------------------------------------------------------------|
|
| ~SPC ?~ or ~SPC s P~ | search with the first found tool with default input |
|
||||||
| ~SPC /~ | execute the first found utility (by default =ag=, =pt=, =ack= and =grep=) |
|
| ~SPC s a p~ | =ag= |
|
||||||
| ~SPC p s a~ | =ag= |
|
| ~SPC s a P~ | =ag= with default text |
|
||||||
| ~SPC p s A~ | =ag= with default text |
|
| ~SPC s g p~ | =grep= with default text |
|
||||||
| ~SPC p s g~ | =grep= with default text |
|
| ~SPC s k p~ | =ack= |
|
||||||
| ~SPC p s k~ | =ack= |
|
| ~SPC s k P~ | =ack= with default text |
|
||||||
| ~SPC p s K~ | =ack= with default text |
|
| ~SPC s t p~ | =pt= |
|
||||||
| ~SPC p s p~ | =pt= |
|
| ~SPC s t P~ | =pt= with default text |
|
||||||
| ~SPC p s P~ | =pt= with default text |
|
|
||||||
|
|
||||||
*Pro Tip* Use ~SPC h l~ to bring back the last helm session.
|
|
||||||
|
|
||||||
**** Searching in an arbitrary directory
|
|
||||||
To use these utilities in one or several arbitrary directories:
|
|
||||||
|
|
||||||
| Key Binding | Description |
|
|
||||||
|-------------+---------------------------------------------------------------------------|
|
|
||||||
| ~SPC f s /~ | execute the first found utility (by default =ag=, =pt=, =ack= and =grep=) |
|
|
||||||
| ~SPC f s a~ | =ag= |
|
|
||||||
| ~SPC f s A~ | =ag= with default text |
|
|
||||||
| ~SPC f s g~ | =grep= |
|
|
||||||
| ~SPC f s G~ | =grep= with default text |
|
|
||||||
| ~SPC f s k~ | =ack= |
|
|
||||||
| ~SPC f s K~ | =ack= with default text |
|
|
||||||
| ~SPC f s p~ | =pt= |
|
|
||||||
| ~SPC f s P~ | =pt= with default text |
|
|
||||||
| ~SPC f s L~ | open stored search buffer (stored with ~F3~ in helm search buffer) |
|
|
||||||
|
|
||||||
*Note* Use the universal argument to change the search list of ~SPC s /~ to
|
|
||||||
=ack= and =grep= (does not look for =ag= or =pt=).
|
|
||||||
|
|
||||||
*Note* It is also possible to search in several directories at once by marking
|
|
||||||
them in the helm buffer.
|
|
||||||
|
|
||||||
*Pro Tip* Use ~F3~ in the helm search buffer to save the list of results to a
|
|
||||||
buffer.
|
|
||||||
|
|
||||||
**** Searching the web
|
**** Searching the web
|
||||||
| Key Binding | Description |
|
| Key Binding | Description |
|
||||||
|
|
|
@ -1484,12 +1484,12 @@ Removes the automatic guessing of the initial value based on thing at point. "
|
||||||
|
|
||||||
;; search with grep
|
;; search with grep
|
||||||
(evil-leader/set-key
|
(evil-leader/set-key
|
||||||
"bsg" 'spacemacs/helm-buffers-do-grep
|
"sgb" 'spacemacs/helm-buffers-do-grep
|
||||||
"bsG" 'spacemacs/helm-buffers-do-grep-region-or-symbol
|
"sgB" 'spacemacs/helm-buffers-do-grep-region-or-symbol
|
||||||
"fsg" 'spacemacs/helm-files-do-grep
|
"sgf" 'spacemacs/helm-files-do-grep
|
||||||
"fsG" 'spacemacs/helm-files-do-grep-region-or-symbol
|
"sgF" 'spacemacs/helm-files-do-grep-region-or-symbol
|
||||||
"sg" 'spacemacs/helm-file-do-grep
|
"sgg" 'spacemacs/helm-file-do-grep
|
||||||
"sG" 'spacemacs/helm-file-do-grep-region-or-symbol)
|
"sgG" 'spacemacs/helm-file-do-grep-region-or-symbol)
|
||||||
|
|
||||||
;; define the key binding at the very end in order to allow the user
|
;; define the key binding at the very end in order to allow the user
|
||||||
;; to overwrite any key binding
|
;; to overwrite any key binding
|
||||||
|
@ -1916,37 +1916,37 @@ If ARG is non nil then `ag' and `pt' and ignored."
|
||||||
"/" 'spacemacs/helm-project-smart-do-search
|
"/" 'spacemacs/helm-project-smart-do-search
|
||||||
"?" 'spacemacs/helm-project-smart-do-search-region-or-symbol
|
"?" 'spacemacs/helm-project-smart-do-search-region-or-symbol
|
||||||
;; opened buffers scope
|
;; opened buffers scope
|
||||||
"b/" 'spacemacs/helm-buffers-smart-do-search
|
"sb" 'spacemacs/helm-buffers-smart-do-search
|
||||||
"b?" 'spacemacs/helm-buffers-smart-do-search-region-or-symbol
|
"sB" 'spacemacs/helm-buffers-smart-do-search-region-or-symbol
|
||||||
"bsa" 'helm-do-ag-buffers
|
"sab" 'helm-do-ag-buffers
|
||||||
"bsA" 'spacemacs/helm-buffers-do-ag-region-or-symbol
|
"saB" 'spacemacs/helm-buffers-do-ag-region-or-symbol
|
||||||
"bsk" 'spacemacs/helm-buffers-do-ack
|
"skb" 'spacemacs/helm-buffers-do-ack
|
||||||
"bsK" 'spacemacs/helm-buffers-do-ack-region-or-symbol
|
"skB" 'spacemacs/helm-buffers-do-ack-region-or-symbol
|
||||||
"bsp" 'spacemacs/helm-buffers-do-pt
|
"stb" 'spacemacs/helm-buffers-do-pt
|
||||||
"bsP" 'spacemacs/helm-buffers-do-pt-region-or-symbol
|
"stB" 'spacemacs/helm-buffers-do-pt-region-or-symbol
|
||||||
;; current file scope
|
;; current file scope
|
||||||
"s/" 'spacemacs/helm-buffers-smart-do-search
|
"ss" 'spacemacs/helm-buffers-smart-do-search
|
||||||
"s?" 'spacemacs/helm-buffers-smart-do-search-region-or-symbol
|
"sS" 'spacemacs/helm-buffers-smart-do-search-region-or-symbol
|
||||||
"sa" 'helm-ag-this-file
|
"saa" 'helm-ag-this-file
|
||||||
"sA" 'spacemacs/helm-file-do-ag-region-or-symbol
|
"saA" 'spacemacs/helm-file-do-ag-region-or-symbol
|
||||||
;; files scope
|
;; files scope
|
||||||
"f/" 'spacemacs/helm-files-smart-do-search
|
"sf" 'spacemacs/helm-files-smart-do-search
|
||||||
"f?" 'spacemacs/helm-files-smart-do-search-region-or-symbol
|
"sF" 'spacemacs/helm-files-smart-do-search-region-or-symbol
|
||||||
"fsa" 'helm-do-ag
|
"saf" 'helm-do-ag
|
||||||
"fsA" 'spacemacs/helm-files-do-ag-region-or-symbol
|
"saF" 'spacemacs/helm-files-do-ag-region-or-symbol
|
||||||
"fsk" 'spacemacs/helm-files-do-ack
|
"skf" 'spacemacs/helm-files-do-ack
|
||||||
"fsK" 'spacemacs/helm-files-do-ack-region-or-symbol
|
"skF" 'spacemacs/helm-files-do-ack-region-or-symbol
|
||||||
"fsp" 'spacemacs/helm-files-do-pt
|
"stf" 'spacemacs/helm-files-do-pt
|
||||||
"fsP" 'spacemacs/helm-files-do-pt-region-or-symbol
|
"stF" 'spacemacs/helm-files-do-pt-region-or-symbol
|
||||||
;; current project scope
|
;; current project scope
|
||||||
"p/" 'spacemacs/helm-project-smart-do-search
|
"sp" 'spacemacs/helm-project-smart-do-search
|
||||||
"p?" 'spacemacs/helm-project-smart-do-search-region-or-symbol
|
"sP" 'spacemacs/helm-project-smart-do-search-region-or-symbol
|
||||||
"psa" 'spacemacs/helm-project-do-ag
|
"sap" 'spacemacs/helm-project-do-ag
|
||||||
"psA" 'spacemacs/helm-project-do-ag-region-or-symbol
|
"saP" 'spacemacs/helm-project-do-ag-region-or-symbol
|
||||||
"psk" 'spacemacs/helm-project-do-ack
|
"skp" 'spacemacs/helm-project-do-ack
|
||||||
"psK" 'spacemacs/helm-project-do-ack-region-or-symbol
|
"skP" 'spacemacs/helm-project-do-ack-region-or-symbol
|
||||||
"psp" 'spacemacs/helm-project-do-pt
|
"stp" 'spacemacs/helm-project-do-pt
|
||||||
"psP" 'spacemacs/helm-project-do-pt-region-or-symbol))
|
"stP" 'spacemacs/helm-project-do-pt-region-or-symbol))
|
||||||
:config
|
:config
|
||||||
(progn
|
(progn
|
||||||
(evil-define-key 'normal helm-ag-map "SPC" evil-leader--default-map)
|
(evil-define-key 'normal helm-ag-map "SPC" evil-leader--default-map)
|
||||||
|
@ -2006,8 +2006,9 @@ If ARG is non nil then `ag' and `pt' and ignored."
|
||||||
"pf" 'helm-projectile-find-file
|
"pf" 'helm-projectile-find-file
|
||||||
"ph" 'helm-projectile
|
"ph" 'helm-projectile
|
||||||
"pp" 'helm-projectile-switch-project
|
"pp" 'helm-projectile-switch-project
|
||||||
"psg" 'helm-projectile-grep
|
"pv" 'projectile-vc
|
||||||
"pv" 'projectile-vc))))
|
"sgp" 'helm-projectile-grep))))
|
||||||
|
|
||||||
|
|
||||||
(defun spacemacs/init-helm-swoop ()
|
(defun spacemacs/init-helm-swoop ()
|
||||||
(use-package helm-swoop
|
(use-package helm-swoop
|
||||||
|
|
Loading…
Reference in a new issue