An ack/ag powered code search and view tool, in an intuitive way with fairly more context.
-
An easy way to install CtrlSF is using a package manager, like pathogen, vundle or neobundle.
In vundle:
Bundle 'dyng/ctrlsf.vim'
-
Read Basic Usage for more.
-
Run
:CtrlSF [pattern]
, it will split a new window to show search result. -
Press
Enter
if you wanna jump to that file, or pressq
to quit. -
Press
p
to explore file in a preview window if you only want a glance. -
Running
:CtrlSFOpen
can reopen CtrlSF window if you are interested in other matches. It is free because it won't invoke a same but new search. -
You can pass arguments like
-i
,-C
or path directly to ack/ag backend in:CtrlSF
command.CtrlSF -i -C 1 [pattern] /restrict/to/some/dir
In CtrlSF window:
o
,Enter
- Jump to file that contains the line under cursor.t
- Likeo
but open file in a new tab.p
- Likeo
but open file in a preview window.O
- Likeo
but always leave CtrlSF window opening.T
- Lkiet
but focus CtrlSF window instead of opened new tab.q
- Quit CtrlSF window.<C-J>
- Move cursor to next match.<C-K>
- Move cursor to previous match.
In preview window:
q
- Close preview window.
-
g:ctrlsf_ackprg
defines the external ack-like program which CtrlSF uses as source. If nothing is specified, CtrlSF will try ag first and fallback to ack if ag is not available. You can also explicitly define it bylet g:ctrlsf_ackprg = 'ag'
-
g:ctrlsf_auto_close
defines the behavior of CtrlSF window after you press theEnter
. By default CtrlSF window will automatically be closed if you jump to some file, you can prevent it by settingg:ctrlsf_auto_close
to 0.let g:ctrlsf_auto_close = 0
-
g:ctrlsf_context
defines how to print lines around the matching line (refer toack
's manual). It is default to be-C 3
, you can overwrite it bylet g:ctrlsf_context = '-B 5 -A 3'
A full doc about options can be found in :help ctrlsf-options
.
- ack.vim depends on vim's builtin
:grep
command, so you can't custom output format. What makes me to write this plugin is that I find reading lines with no highlight and no context is totally a pain. (Using:cnext
and:cprevious
can relieve it, yes.) - Fix a misescape bug in ack.vim (and also ag.vim), it lets you can use literal '#' and '%' without annoying escape now. For more information, check manual of ack.vim.
- ag.vim is actually a fork of ack.vim with minor change.