Skip to content

Commit 43848ab

Browse files
author
Harshad Srinivasan
committed
Added replace functions
1 parent c9f915e commit 43848ab

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

plugin/bullets.vim

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -558,10 +558,8 @@ endfun
558558
fun! s:set_checkbox(lnum, marker)
559559
let l:initpos = getpos('.')
560560
let l:pos = s:find_checkbox_position(a:lnum)
561-
let l:checkbox_content = getline(a:lnum)[l:pos]
562561
" select inside checkbox
563-
call setpos('.', [0, a:lnum, l:pos])
564-
execute 'normal! ci[' . a:marker
562+
call s:replace(a:lnum, l:pos, a:marker)
565563
call setpos('.', l:initpos)
566564
endfun
567565

@@ -1244,6 +1242,16 @@ fun! s:sibling_checkbox_status(lnum)
12441242
return l:checkbox_markers[l:completion]
12451243
endfun
12461244

1245+
fun! s:replace_char(lnum, col, item)
1246+
call s:replace(a:lnum, a:col - 1, a:col + 1, a:item)
1247+
endfun
1248+
1249+
fun! s:replace(lnum, col_start, col_end, item)
1250+
let l:curline = getline(a:lnum)
1251+
let l:newline = l:curline[0: a:col_start] . a:item . l:curline[a:col_end: -1]
1252+
call setline(a:lnum, l:newline)
1253+
endfun
1254+
12471255
" ------------------------------------------------------- }}}
12481256

12491257
" Restore previous external compatibility options --------- {{{

0 commit comments

Comments
 (0)