summaryrefslogtreecommitdiff
path: root/vim/.vim/after/plugin/generalized_motion.vim
blob: a2b42846211641efa280dc700612488c3f5a8672 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"" 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
        if (g:generalized_motion == "s") | call feedkeys("\<Plug>Sneak_s") | return | endif
    endif
    if (g:generalized_motion == "f") | call feedkeys(';', 'n') | endif
    if (g:generalized_motion == "t") | call feedkeys(';', 'n') | endif
    if (g:generalized_motion == "s") | call feedkeys("\<Plug>Sneak_;") | return | 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
        if (g:generalized_motion == "]f") | call feedkeys("\<Plug>unimpairedDirectoryPrevious") | endif
        if (g:generalized_motion == "[f") | call feedkeys("\<Plug>unimpairedDirectoryPrevious") | endif
    catch
        call feedkeys(';', 'n')
    endtry
endfunction
for mapping in ['f', 't', 's', ']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>