File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -65,6 +65,14 @@ Find commits for cur buf :BCommits N
6565Find normal mode mapping :Maps N
6666Find help tags :Helptags N
6767}}}
68+ Search within files and replace{{{
69+ Search within files matching "my-file-pattern' containing "pattern" :grep my-pattern my-file-pattern
70+ View search's grep result :copen
71+ Keep only grep's result in files FOO/bar :cfilter FOO/bar
72+ Filter out all grep's result in files FOO/bar :cfilter! FOO/bar
73+ Filter out the result under the quickfix cursor from grep's result :x
74+ Replace FOO with BAR in grep results :cfdo %s/FOO/BAR/g
75+ }}}
6876Keycodes {{{2
6977All keycodes like <S-..>, :keycodes N
7078}}}
Original file line number Diff line number Diff line change 44" upcase search is case sensitive
55" --uu : seach in all text files, including ignored ones
66set grepprg = rg\ -- vimgrep \ -- smart- case \ - uu
7+
8+ " Load ability to filter quickfix search result with :Cfilter FOO/bar
9+ packadd ! cfilter
10+
11+ " src: https://blog.beezwax.net/advanced-search-and-replace-with-vim/
12+ function ! s: QfRemoveAtCursor () abort
13+ let currline = line (' .' )
14+ let items = getqflist ()- >filter ({ index - > (index + 1 ) != currline })
15+ call setqflist (items , ' r' )
16+ execute ' normal ' . currline . ' G'
17+ endfunction
18+
19+ augroup quickfix
20+ autocmd !
21+ autocmd FileType qf nnoremap <buffer><silent> x :call <SID>QfRemoveAtCursor()<CR>
22+ augroup END
You can’t perform that action at this time.
0 commit comments