@@ -10,28 +10,37 @@ if (exists ('g:loaded_deleteto') || &cp || (v:version < 700))
1010endif
1111let g: loaded_deleteto = 1
1212
13- function ! s: delete_to (start , stop , count , char )
13+ function ! s: delete_to (start , stop , char, count )
1414let l: esc_char = escape (a: char , ' !\' )
1515let l: cmd = a: start . ' ,' . a: stop . ' s!\V\^\(\[^' . l: esc_char . ' ]\*' . l: esc_char . ' \)\{,' . a: count . ' \}!!'
1616execute l: cmd
1717endfunction
1818
19- function ! s: go (... )
19+ function ! s: go_map (... )
2020if (a: 0 == 2 )
2121let [l: start , l: stop ] = [a: 1 , a: 2 ]
2222else
2323let [l: start , l: stop ] = [line (' ' ' [' ), line (' ' ' ]' )]
2424endif
2525
2626let l: char = nr2char (getchar ())
27- call s: delete_to (l: start , l: stop , v: count1 , l: char )
27+ call s: delete_to (l: start , l: stop , l: char , v: count1 )
28+ endfunction
29+
30+ function ! s: go_command (... )
31+ if (a: 0 == 3 )
32+ let num = 1
33+ else
34+ let num = a: 4
35+ endif
36+ call s: delete_to (a: 1 , a: 2 , a: 3 , num)
2837endfunction
2938
3039function ! s: set_up_mappings ()
31- nnoremap <silent> <Plug> DeleteToA :<C-U> call <SID> go (1, line ('$'))<CR>
32- nnoremap <silent> <Plug> DeleteToL :<C-U> call <SID> go (line ('.'), line ('.'))<CR>
33- nnoremap <silent> <Plug> DeleteToM :<C-U> set opfunc=<SID> go <CR> g@
34- xnoremap <silent> <Plug> DeleteToV :<C-U> call <SID> go (line ('''<'), line ('''> '))<CR>
40+ nnoremap <silent> <Plug> DeleteToA :<C-U> call <SID> go_map (1, line ('$'))<CR>
41+ nnoremap <silent> <Plug> DeleteToL :<C-U> call <SID> go_map (line ('.'), line ('.'))<CR>
42+ nnoremap <silent> <Plug> DeleteToM :<C-U> set opfunc=<SID> go_map <CR> g@
43+ xnoremap <silent> <Plug> DeleteToV :<C-U> call <SID> go_map (line ('''<'), line ('''> '))<CR>
3544
3645" Four mappings for the commands
3746" DeleteToA all the file
@@ -49,3 +58,5 @@ endfunction
4958
5059call s: set_up_mappings ()
5160
61+ command ! -range =% -nargs =+ DeleteTo call <SID> go_command (<line1> , <line2> , <f-args> )
62+
0 commit comments