vim-markdown
vim-markdown copied to clipboard
feature request: remove hanging bullet points
This is a relatively small nit but one I come across all the time. Exiting a list with the default settings has a lot of friction. Consider the following state:
* item one
* item two[cursor]
in insert mode, pressing enter
will add a bullet (and keep adding them)
* item one
* item two
* [cursor]
which you then have to clear with backspace or somesuch, but then pressing enter again to move to a new line adds an indent, which you also have to clear
* item one
* item two
[cursor]
so in all, what would have been <enter><enter>
in a word processor has turned into a janky sequence of finger acrobatics. I think the following changes would help:
while the cursor is at the end of the line on the last bullet point of a list (as in second example above) pressing <enter>
in normal mode will
- add a new line (normal behaviour)
- without any indentation
- and the hanging bullet will be deleted
resulting in the following state:
* item one
* item two
[cursor]
which you then have to clear with backspace or somesuch, but then pressing enter again to move to a new line adds an indent, which you also have to clear
This behavior can apparently be controlled:
let g:vim_markdown_new_list_item_indent = 0
~~I have no idea how to deal with deleting the hanging bullet on Enter though, a fix would've been awesome.~~
Modified an answer from an SO post about automatically removing comment leaders for fixing the hanging bullet on Enter issue:
inoremap <expr> <CR> getline(".") =~ '\v^\s*(\-\|\*)\s*$' ? "\<C-u><CR>" : "\<CR>"
Put them in ~/.vim/after/ftplugin/markdown.vim
or set them up as an autocmd
.
Apologies resurrecting this zombie, but I'm trying to use @sudormrfbin's inoremap
solution and ending up with this error:
Error detected while processing VimEnter Autocommands for "*"..function <SNR>90_MapCR:
line 8:
E10: \ should be followed by /, ? or &
Press ENTER or type command to continue
I have very little vimscript knowledge so not really sure how to troubleshoot. Removed some of the escape slashes to see if I could isolate the issue, but couldn't figure it out. Same error shows up if I run vim -u NONE
and add the map at the command line.