diff options
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/commenter.vim | 26 | ||||
-rw-r--r-- | plugin/fall.vim | 9 | ||||
-rw-r--r-- | plugin/remappings.vim | 60 |
3 files changed, 33 insertions, 62 deletions
diff --git a/plugin/commenter.vim b/plugin/commenter.vim index f903fce..8d283c3 100644 --- a/plugin/commenter.vim +++ b/plugin/commenter.vim @@ -13,11 +13,6 @@ vnoremap i/ <cmd>call <sid>comment_obj('', 'i')<cr> onoremap a/ <cmd>call <sid>comment_obj(v:operator, 'a')<cr> vnoremap a/ <cmd>call <sid>comment_obj('', 'a')<cr> -" Objects for paragraphs excluding any comment blocks immediately preceeding or -" Succeeding -onoremap acp <cmd>call <sid>uncommented_paragraph('a')<cr> -onoremap icp <cmd>call <sid>uncommented_paragraph('i')<cr> - noremap czd <cmd>set operatorfunc=<sid>uncomment<cr>g@ nnoremap czdd <cmd>set operatorfunc=<sid>uncomment<cr>g@_ @@ -71,27 +66,6 @@ function! s:minpos(cur, oth) endfunction -function! s:uncommented_paragraph(t) abort - let savepos = getpos('.') - set operatorfunc=s:save_object - exec "normal! g@". a:t . "pv\<esc>" - call setpos('.', savepos) - - let [start_regex, end_regex] = g:GetCommentRegex('a') - - call search(end_regex . '\|\%^', 'cb') - exec "normal! j" - call setpos('.', s:maxpos(getpos('.'), s:object.start)) - normal! m< - call setpos('.', savepos) - - call search(start_regex . '\|\%$', 'c') - call setpos('.', s:minpos(getpos('.'), s:object.end)) - exec "normal! k" - - normal! m>gvV -endfunction - function! s:regex_combine(s1, s2) abort if a:s1 == "" return a:s2 diff --git a/plugin/fall.vim b/plugin/fall.vim index 0001c37..8de1780 100644 --- a/plugin/fall.vim +++ b/plugin/fall.vim @@ -34,3 +34,12 @@ vnoremap <silent> ii <cmd>exec "normal! " \ . fall#fall('j', '^\s*$') \ . "kO" \ . fall#fall('k', '^\s*$') . 'j' <cr> + +vnoremap <expr> <silent> ic fall#visual_same_character("jk") +onoremap <silent> ic <cmd>exec "normal! V" . fall#visual_same_character("jk")<cr> + +vnoremap <expr> <silent> ijc fall#visual_same_character("j") +onoremap <silent> ijc <cmd>exec "normal! V" . fall#visual_same_character("j")<cr> + +vnoremap <expr> <silent> ikc fall#visual_same_character("k") +onoremap <silent> ikc <cmd>exec "normal! V" . fall#visual_same_character("k")<cr> diff --git a/plugin/remappings.vim b/plugin/remappings.vim index f29f0a4..90d12e0 100644 --- a/plugin/remappings.vim +++ b/plugin/remappings.vim @@ -2,43 +2,31 @@ " Remap i{",',`} and a{",',`} to search for the next string. This is more like how objects like i( and i{ work. " " The behavior inside the quotes should remain unchanged. -onoremap <silent> i" <cmd>call <sid>find_quote('i', '"')<cr> -onoremap <silent> a" <cmd>call <sid>find_quote('a', '"')<cr> -onoremap <silent> i' <cmd>call <sid>find_quote('i', "'")<cr> -onoremap <silent> a' <cmd>call <sid>find_quote('a', "'")<cr> -onoremap <silent> i` <cmd>call <sid>find_quote('i', '`')<cr> -onoremap <silent> a` <cmd>call <sid>find_quote('a', '`')<cr> -vnoremap <silent> i" <cmd>call <sid>find_quote('i', '"')<cr> -vnoremap <silent> a" <cmd>call <sid>find_quote('a', '"')<cr> -vnoremap <silent> i' <cmd>call <sid>find_quote('i', "'")<cr> -vnoremap <silent> a' <cmd>call <sid>find_quote('a', "'")<cr> -vnoremap <silent> i` <cmd>call <sid>find_quote('i', '`')<cr> -vnoremap <silent> a` <cmd>call <sid>find_quote('a', '`')<cr> - -function! s:find_quote(ai, q) abort - let l = getline('.')[:col('.') - 2] - - let cnt = 0 - let skip = 0 - for c in l - if c ==# a:q && !skip - let cnt = !cnt - endif - - if c ==# '\' - let skip = 1 - else - let skip = 0 - endif - endfor - - let flags = 'W' - if cnt == 1 - let flags .= 'b' +onoremap <silent> in" <cmd>call <sid>find_next_quote('i', '"')<cr> +onoremap <silent> an" <cmd>call <sid>find_next_quote('a', '"')<cr> +onoremap <silent> in' <cmd>call <sid>find_next_quote('i', "'")<cr> +onoremap <silent> an' <cmd>call <sid>find_next_quote('a', "'")<cr> +onoremap <silent> in` <cmd>call <sid>find_next_quote('i', '`')<cr> +onoremap <silent> an` <cmd>call <sid>find_next_quote('a', '`')<cr> +vnoremap <silent> in" <cmd>call <sid>find_next_quote('i', '"')<cr> +vnoremap <silent> an" <cmd>call <sid>find_next_quote('a', '"')<cr> +vnoremap <silent> in' <cmd>call <sid>find_next_quote('i', "'")<cr> +vnoremap <silent> an' <cmd>call <sid>find_next_quote('a', "'")<cr> +vnoremap <silent> in` <cmd>call <sid>find_next_quote('i', '`')<cr> +vnoremap <silent> an` <cmd>call <sid>find_next_quote('a', '`')<cr> + +function! s:find_next_quote(ai, q) abort + call search(a:q, '') + call search(a:q, '') + + let l = getline(line('.')) + let c = col('.') - 1 + + if l[c] == a:q && l[c - 1] == a:q + exec "normal! i " + elseif l[c] == a:q && l[c + 1] == a:q + exec "normal! a l" endif - - exec "normal! \<esc>" - call search(a:q . '\zs.', flags) exec "normal! v" . a:ai . a:q endfunction |