dotar/vim/settings/search.vim

31 lines
840 B
VimL
Raw Normal View History

2014-02-16 11:08:32 +08:00
function! GetVisual()
let reg_save = getreg('"')
let regtype_save = getregtype('"')
let cb_save = &clipboard
set clipboard&
normal! ""gvy
let selection = getreg('"')
call setreg('"', reg_save, regtype_save)
let &clipboard = cb_save
return selection
endfunction
"grep the current word using ,k (mnemonic Kurrent)
2019-04-11 13:06:33 +08:00
nnoremap <silent> ,k :Ag <cword><CR>
2014-02-16 11:08:32 +08:00
"grep visual selection
2019-04-11 13:06:33 +08:00
vnoremap ,k :<C-U>execute "Ag " . GetVisual()<CR>
2014-02-16 11:08:32 +08:00
"grep current word up to the next exclamation point using ,K
2019-04-11 13:06:33 +08:00
nnoremap ,K viwf!:<C-U>execute "Ag " . GetVisual()<CR>
2014-02-16 11:08:32 +08:00
"grep for 'def foo'
2019-04-11 13:06:33 +08:00
nnoremap <silent> ,gd :Ag 'def <cword>'<CR>
2014-02-16 11:08:32 +08:00
2019-04-11 13:06:33 +08:00
",gg = Grep! - using Ag the silver searcher
2014-02-16 11:08:32 +08:00
" open up a grep line, with a quote started for the search
2019-04-11 13:06:33 +08:00
nnoremap ,gg :Ag ""<left>
2014-02-16 11:08:32 +08:00
"Grep for usages of the current file
2019-04-11 13:06:33 +08:00
nnoremap ,gcf :exec "Ag " . expand("%:t:r")<CR>