diff options
author | Urbain Vaes <urbain@vaes.uk> | 2018-12-17 18:37:47 +0100 |
---|---|---|
committer | Urbain Vaes <urbain@vaes.uk> | 2018-12-17 18:37:47 +0100 |
commit | ee96831c8b9ec7c5a77466f888e792d0f43103d5 (patch) | |
tree | 43f0bcaf63e88ec3f9e15e49e65af61c4cf7e8a3 /vim/.vim/after/plugin/generalized_motion.vim | |
parent | 77cd142cbfceda8d4fe644acff46b7f8a3463e9e (diff) |
[vim] Add mapping to cycle quickfix more easily
Diffstat (limited to 'vim/.vim/after/plugin/generalized_motion.vim')
-rw-r--r-- | vim/.vim/after/plugin/generalized_motion.vim | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/vim/.vim/after/plugin/generalized_motion.vim b/vim/.vim/after/plugin/generalized_motion.vim new file mode 100644 index 0000000..87ea9ed --- /dev/null +++ b/vim/.vim/after/plugin/generalized_motion.vim @@ -0,0 +1,26 @@ +"" More general ; {{{1 +let g:generalized_motion = "f" +function! Generalized_motion(...) + if a:0 > 0 + let g:generalized_motion=a:1 + echom "Generalized motion:" g:generalized_motion + if (g:generalized_motion == "f") | call feedkeys('f', 'n') | return | endif + if (g:generalized_motion == "t") | call feedkeys('t', 'n') | return | endif + endif + if (g:generalized_motion == "f") | call feedkeys(';', 'n') | endif + if (g:generalized_motion == "t") | call feedkeys(';', 'n') | endif + try + if (g:generalized_motion == "]q") | cnext | endif + if (g:generalized_motion == "[q") | cprevious | endif + if (g:generalized_motion == "]a") | next | endif + if (g:generalized_motion == "[a") | previous | endif + if (g:generalized_motion == "]b") | bnext | endif + if (g:generalized_motion == "[b") | bprevious | endif + catch + call feedkeys(';', 'n') + endtry +endfunction +for mapping in ['f', 't', ']q', '[q', ']a', '[a', ']f', '[f', ']b', '[b'] + exe "nmap <silent>" mapping ":<c-u>call Generalized_motion('".mapping."')<cr>" +endfor +nnoremap <silent> ; :<c-u>call Generalized_motion()<cr> |