Searching
With an external tool
SpaceVim can be interfaced with different searching tools like:
- rg - ripgrep
- ag - the silver searcher
- pt - the platinum searcher
- ack
- grep
The search commands in SpaceVim are organized under theSPC s
prefix with the next key is the tool to use and the last key is the scope. For instanceSPC s a b
will search in all opened buffers usingag
.
If the last key (determining the scope) is uppercase then the current word under the cursor is used as default input for the search. For instance SPC s a B
will search with word under cursor.
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 g:spacevim_search_tools
, the default order is rg
, ag
, pt
, ack
then grep
. For instance SPC s b
will search in the opened buffers using pt
if rg
and ag
have not been found on the system.
The tool keys are:
Tool | Key |
---|---|
ag | a |
grep | g |
ack | k |
rg | r |
pt | t |
The available scopes and corresponding keys are:
Scope | Key |
---|---|
opened buffers | b |
buffer directory | d |
files in a given directory | f |
current project | p |
It is possible to search in the current file by double pressing the second key of the sequence, for instance SPC s a a
will search in the current file with ag
.
Notes:
- rg, 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 unite buffer.
Beware if you usept
, TCL parser tools also install a command line tool calledpt
.
Useful key bindings
Key Binding | Description |
---|---|
SPC r l |
resume the last completion buffer |
SPC s ` |
go back to the previous place before jump |
Prefix argument | will ask for file extensions |
Searching in current file
Key Binding | Description |
---|---|
SPC s s |
search with the first found tool |
SPC s S |
search with the first found tool with default input |
SPC s a a |
ag |
SPC s a A |
ag with default input |
SPC s g g |
grep |
SPC s g G |
grep with default input |
SPC s r r |
rg |
SPC s r R |
rg with default input |
Searching in buffer directory
Key Binding | Description |
---|---|
SPC s d |
searching in buffer directory with default tool |
SPC s D |
searching in buffer directory cursor word with default tool |
SPC s a d |
searching in buffer directory with ag |
SPC s a D |
searching in buffer directory cursor word with ag |
SPC s g d |
searching in buffer directory with grep |
SPC s g D |
searching in buffer directory cursor word with grep |
SPC s k d |
searching in buffer directory with ack |
SPC s k D |
searching in buffer directory cursor word with ack |
SPC s r d |
searching in buffer directory with rg |
SPC s r D |
searching in buffer directory cursor word with rg |
SPC s t d |
searching in buffer directory with pt |
SPC s t D |
searching in buffer directory cursor word with pt |
Searching in all loaded buffers
Key Binding | Description |
---|---|
SPC s b |
search with the first found tool |
SPC s B |
search with the first found tool with default input |
SPC s a b |
ag |
SPC s a B |
ag with default input |
SPC s g b |
grep |
SPC s g B |
grep with default input |
SPC s k b |
ack |
SPC s k B |
ack with default input |
SPC s r b |
rg |
SPC s r B |
rg with default input |
SPC s t b |
pt |
SPC s t B |
pt with default input |
Searching 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 r f |
rg |
SPC s r F |
rg with default text |
SPC s t f |
pt |
SPC s t F |
pt with default text |
Searching in a project
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 s a p |
ag |
SPC s a P |
ag with default text |
SPC s g p |
grep |
SPC s g p |
grep with default text |
SPC s k p |
ack |
SPC s k P |
ack with default text |
SPC s t p |
pt |
SPC s t P |
pt with default text |
SPC s r p |
rg |
SPC s r P |
rg with default text |
Hint: It is also possible to search in a project without needing to open a file beforehand. To do so use SPC p p
and then C-s
on a given project to directly search into it like with SPC s p
. (TODO)
Background searching in a project
Background search keyword in a project, when searching done, the count will be shown on the statusline.
Key Binding | Description |
---|---|
SPC s j |
searching input expr background with the first found tool |
SPC s J |
searching cursor word background with the first found tool |
SPC s l |
List all searching result in quickfix buffer |
SPC s a j |
ag |
SPC s a J |
ag with default text |
SPC s g j |
grep |
SPC s g J |
grep with default text |
SPC s k j |
ack |
SPC s k J |
ack with default text |
SPC s t j |
pt |
SPC s t J |
pt with default text |
SPC s r j |
rg |
SPC s r J |
rg with default text |
Searching the web
Key Binding | Description |
---|---|
SPC s w g |
Get Google suggestions in vim. Opens Google results in Browser. |
SPC s w w |
Get Wikipedia suggestions in vim. Opens Wikipedia page in Browser.(TODO) |
Note: to enable google suggestions in vim, you need to add let g:spacevim_enable_googlesuggest = 1
to your custom Configuration file.
Searching on the fly
Key Binding | Description |
---|---|
SPC s g G |
Searching in project on the fly with default tools |
key binding in FlyGrep buffer:
Key Binding | Description |
---|---|
<Esc> |
close FlyGrep buffer |
<Enter> |
open file at the cursor line |
<Tab> |
move cursor line down |
<S-Tab> |
move cursor line up |
<Bs> |
remove last character |
<C-w> |
remove the Word before the cursor |
<C-u> |
remove the Line before the cursor |
<C-k> |
remove the Line after the cursor |
<C-a> /<Home> |
Go to the beginning of the line |
<C-e> /<End> |
Go to the end of the line |
Persistent highlighting
SpaceVim uses g:spacevim_search_highlight_persist
to keep the searched expression highlighted until the next search. It is also possible to clear the highlighting by pressing SPC s c
or executing the ex command :noh
.
Highlight current symbol
SpaceVim supports highlighting of the current symbol on demand and add a transient state to easily navigate and rename these symbol.
It is also possible to change the range of the navigation on the fly to:
- buffer
- function
- visible area
To Highlight the current symbol under point pressSPC s h
.
Navigation between the highlighted symbols can be done with the commands:
Key Binding | Description |
---|---|
* |
initiate navigation transient state on current symbol and jump forwards |
# |
initiate navigation transient state on current symbol and jump backwards |
SPC s e |
edit all occurrences of the current symbol |
SPC s h |
highlight the current symbol and all its occurrence within the current range |
SPC s H |
go to the last searched occurrence of the last highlighted symbol |
In highlight symbol transient state:
Key Binding | Description |
---|---|
e |
edit occurrences (* ) |
n |
go to next occurrence |
N /p |
go to previous occurrence |
b |
search occurrence in all buffers |
/ |
search occurrence in whole project |
Tab |
toggle highlight current occurrence |
r |
change range (function, display area, whole buffer) |
R |
go to home occurrence (reset position to starting occurrence) |
Any other key | leave the navigation transient state |