Mappings
Could you make mappings changeable in .vimrc? (Like in https://github.com/Valloric/ListToggle -- and itegrate its functionality -- only two mappings really! if possible).
In current state I can't replace mappings which need 'l:matches_window_prefix' to be set. As workaround, this file local var can be replaced with buffer local -- then I could use it in ftplugin for my own mappings.
P.S. At work I often search in kernel sources and preview feature 'go' is very useful for it.
But pressing 'go' for 20-50 entries isn't much pleasing. As temporary workaround I use direct mapping in ftplugin/qf.vim "nnoremap
How about your proper mappings in qf.vim by adding (as a starter)
let s:qf_mappings = {
\ "o": "<CR>",
\ "O": "<CR><c-w>p",
\ "q": "<C-W>c" }
for key_map in items(s:qf_mappings)
execute printf("nnoremap <buffer><nowait><silent> %s %s", get(key_map, 0), get(key_map, 1))
endfor
?
This way, they are available even if the qflist was populated by other means than ag.vim.
NB: O is Ag's go
However this snippet have not solved problem of l:matches_window_prefix, which determines kind of window we are working in, but you gave me one more viewpoint for idea. So, using your link notion at https://github.com/thinca/vim-qfreplace/issues/5 , resulting solution seems like:
" file: ~/.vim/after/ftplugin/qf.vim
" Thanks to: https://github.com/romainl/dotvim/blob/master/bundle/qf/after/ftplugin/qf.vim
" are we in a location list or a quickfix list?
let b:isLoc = len(getloclist(0)) > 0 ? 1 : 0
let b:wPref = b:isLoc ? 'l' : 'c'
"" Rule of Thumb: reuse editing mappings, and don't touch navigation
" q/<Space> - close / jump,
" o/O - preview/jump of and stay, I - jump into and close,
" x/X - exchange to tab foregr/backgr, S/H - split vert/horz,
let s:qf_mappings = {
\ 'q' : ':#close<CR>',
\ 'o' : '<CR><C-w>p',
\ 'O' : '<CR>',
\ 'I' : '<CR><C-w><C-w>:#close<CR>',
\ 'S' : '<C-w><CR><C-w>L<C-w>p<C-w>J<C-w>p',
\ 'H' : '<C-W><CR><C-w>K<C-w>b',
\ 'x' : '<C-w><CR><C-w>T',
\ 'X' : '<C-w><CR><C-w>TgT<C-W><C-W>',
\ '<Space>' : '<CR>',
\ }
for key_map in items(s:qf_mappings)
exec printf("nnoremap <buffer><nowait><silent> %s %s", get(key_map, 0)
\ , substitute(get(key_map, 1), '#', b:wPref, 'g'))
endfor
Issue can be closed, due to changed solution orientation.
Cool,
Note that the solution further down in the qfreplace thread is more stable than that by getloclist().
When albfan/ag.vim #21 enabling user customization will be implemented and merged into trunk, this issue could be finally closed.
@amerlyq I'm using rking/ag.vm .how about you fork, does it contains replace func? just like easygrep
Don't know what about vim-easygrep, because its code for me seemed rather obscure and overbloated to try it even once.
I use combo of ag.vim with quickfix-reflector.vim when need to do some multi-file replacements. For me editing directly in qf seems much easier.
now the most use tool for me is Unite , here is the link https://github.com/Shougo/unite.vim
it is a source tools ,you can create yourself source and ,shown by Unite
The map of mappings idea would work, but I wonder if there's a way to make a new filetype yet retain all the quickfix/location list features. If we could do that, then we could just set all the mappings in an autogroup and let people disable that or map over the mappings themselves. That might be more natural, though I've never heard of being able to alias a file type.