bullets.vim
bullets.vim copied to clipboard
[Feature Request] Add support for O to insert a new bullet item on the line above the cursor
There is existing functionality for o which creates a new bullet item on the line below the cursor and re-numbers all subsequent items. If I want to insert a new bullet item as the first item in the list, I currently have to create it manually and then re-number all the items. It would be nice if hitting O while on the first item of a list would create a new item in the first position and re-number following items automatically.
quick and not perfect workaround:
let g:bullets_custom_mappings = [
\ ['nmap', 'O', 'k<Plug>(bullets-newline)'],
\]
function! SmartBulletsNewlineAbove()
let l:save_cursor = getcurpos()
let l:current_line_num = l:save_cursor[1]
execute "normal! \<Plug>(bullets-newline)"
if line('.') > l:current_line_num
execute line('.') . 'move ' . (l:current_line_num - 1)
endif
execute "normal! \<Plug>(bullets-renumber)"
call setpos('.', [0, l:current_line_num, 0, 0])
call feedkeys('A', 'n')
endfunction
let g:bullets_custom_mappings = [
\ ['nmap', 'O', ':call SmartBulletsNewlineAbove()<CR>'],
\ ]