In Vim, I can type a line like this:
- When in the Course of human events it becomes necessary for one people
to dissolve the political bands which have connected them with another
...
and Vim will wrap the text so that it aligns to the right of the dash. But if I try this with an asterisk, this is what happens:
* When in the Course of human events it becomes necessary for one people
to dissolve the political bands which have connected them with another
...
Is there a way to make the autoindent work with the leading asterisk in the same way it does for the leading dash?
Usage. In markdown or a text file start a bulleted list using - or * . Press return to go to the next line, a new list item will be created.
Bullet points use three important markers to determine where the bullet and the text will appear. First Line Indent - This is the distance from the left margin to the bullet and indicates if there is any indentation. All the built-in bullet formats are indented by 0.63cm.
This is done using the comments
setting (see :help 'comments'
and :help format-comments
).
The setting you need to add is fb:*
, which says that there is a comment type that starts with *
and the *
must be followed by a blank and is only on the first line of the comment. Vim handles the rest. However, note that default settings include *
as the middle of a multi-line C comment, so you'll need to disable this.
If the hyphen-prefixed and asterisk-prefixed lines are the only ones you want to work like this, do this:
set comments=fb:-,fb:*
Alternatively, tweak the default comments setting as you like: :set comments?
shows the current setting and :help format-comments
explains what it all means.
If you want this to be specific to a file type, create a file in ~/.vim/ftplugin
(or vimfiles
on Windows) with a filename as extension.vim
(e.g. txt.vim
for .txt
files). In this file put:
setlocal comments=fb:-,fb:*
This will configure the comments
setting for the relevant file type without affecting other files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With