Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mappings #76

Open
amerlyq opened this issue Dec 15, 2014 · 9 comments
Open

Mappings #76

amerlyq opened this issue Dec 15, 2014 · 9 comments

Comments

@amerlyq
Copy link

amerlyq commented Dec 15, 2014

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 :copen". But in such case I can't use location lists (I need that l:matches_window_prefix, which local to your plugin only :( )

@Konfekt
Copy link

Konfekt commented Jan 29, 2015

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

@amerlyq
Copy link
Author

amerlyq commented Mar 10, 2015

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 thinca/vim-qfreplace#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.

@Konfekt
Copy link

Konfekt commented Mar 11, 2015

Cool,

Note that the solution further down in the qfreplace thread is more stable than that by getloclist().

@amerlyq
Copy link
Author

amerlyq commented Nov 21, 2015

When albfan/ag.vim #21 enabling user customization will be implemented and merged into trunk, this issue could be finally closed.

@wsdjeg
Copy link

wsdjeg commented Dec 14, 2015

@amerlyq I'm using rking/ag.vm .how about you fork, does it contains replace func?
just like easygrep

@amerlyq
Copy link
Author

amerlyq commented Dec 14, 2015

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.

@wsdjeg
Copy link

wsdjeg commented Dec 14, 2015

now the most use tool for me is Unite , here is the link https://github.com/Shougo/unite.vim

@wsdjeg
Copy link

wsdjeg commented Dec 14, 2015

it is a source tools ,you can create yourself source and ,shown by Unite

@losingkeys
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants