Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
misterbuckley opened this issue Jun 25, 2021 · 2 comments

Comments

@misterbuckley
Copy link

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.

@kraxli
Copy link

kraxli commented Jan 12, 2023

quick and not perfect workaround:

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

@VimWei
Copy link

VimWei commented Apr 2, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants