Skip to content

Instantly share code, notes, and snippets.

@syl20bnr
Created June 16, 2015 03:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save syl20bnr/8a9e8ec1b4ef3ab90532 to your computer and use it in GitHub Desktop.
Save syl20bnr/8a9e8ec1b4ef3ab90532 to your computer and use it in GitHub Desktop.

Spacemacs can be interfaced with different search utilities like:

The search commands in Spacemacs are organized under the SPC s prefix with 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:

ToolKey
aga
grepg
ackk
ptt

The available scopes and corresponding keys are:

ScopeKey
opened buffersb
files in a given directoryf
current projectp

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, TCL parser tools also install a command line tool called pt.

Useful key bindings

Key BindingDescription
SPC h lresume the last helm buffer
F3in a helm buffer, convert a helm search buffer into a regular buffer
SPC s Lfocus the last converted search buffer
Prefix argumentwill ask for file extensions

Searching in current file

Key BindingDescription
SPC s ssearch with the first found tool
SPC s Ssearch with the first found tool with default input
SPC s a aag
SPC s a Aag with default input
SPC s g ggrep
SPC s g Ggrep with default input

Searching in all open buffers visiting files

Key BindingDescription
SPC s bsearch with the first found tool
SPC s Bsearch with the first found tool with default input
SPC s a bag
SPC s a Bag with default text
SPC s g bgrep
SPC s g Bgrep with default text
SPC s k back
SPC s k Back with default text
SPC s t bpt
SPC s t Bpt with default text

Searching for files in an arbitrary directory

Key BindingDescription
SPC s fsearch with the first found tool
SPC s Fsearch with the first found tool with default input
SPC s a fag
SPC s a Fag with default text
SPC s g fgrep
SPC s g Fgrep with default text
SPC s k fack
SPC s k Fack with default text
SPC s t fpt
SPC s t Fpt with default text

Searching in a project

Key BindingDescription
SPC / or SPC s psearch with the first found tool
SPC ? or SPC s Psearch with the first found tool with default input
SPC s a pag
SPC s a Pag with default text
SPC s g pgrep with default text
SPC s k pack
SPC s k Pack with default text
SPC s t ppt
SPC s t Ppt with default text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment