bullets.vim icon indicating copy to clipboard operation
bullets.vim copied to clipboard

[Feature Request] Add support for O to insert a new bullet item on the line above the cursor

Open misterbuckley opened this issue 4 years ago • 2 comments

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.

misterbuckley avatar Jun 25 '21 15:06 misterbuckley

quick and not perfect workaround:

let g:bullets_custom_mappings = [
    \ ['nmap', 'O', 'k<Plug>(bullets-newline)'],
\]

kraxli avatar Jan 12 '23 22:01 kraxli

    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>'],
    \ ]

VimWei avatar Apr 02 '24 15:04 VimWei