Markdown List Extension for VSCode
This extension is based on the listEditing.ts file of the Markdown Support extension. Thanks to the author and all contributors!
Description generated by AI!
I'm too lazy to write it myself.=)
This VSCode extension enhances your experience editing Markdown files by automatically handling various list formats. It supports task lists, ordered and unordered lists, blockquotes, and proper indentation.
Features
- Continue Lists: Automatically continues unordered or ordered lists with the appropriate list markers when you press
Enter
.
- Task List Management: Easily manage task lists by adding or removing checkboxes (
[ ]
and [x]
).
- Blockquote Handling: Automatically continues blockquotes when pressing
Enter
.
- Indentation: Properly outdents or indents list items based on the current structure of the document.
Activation
The extension is activated under the following conditions:
- When you open a file with the Markdown language (
.md
), R Markdown (.rmd
), or Quarto (.qmd
).
- When a workspace contains a
README.md
file.
These conditions ensure that the extension only activates when you are working on relevant file types or a project that includes a README.md
file.
Keybinding
This extension is configured to work with the Enter
key when:
- The editor has text focus (
editorTextFocus
).
- The document language is Markdown (
editorLangId =~ /^markdown$|^rmd$|^quarto$/
).
- The editor is not in readonly mode (
!editorReadonly
).
- No suggestion widget is visible (
!suggestWidgetVisible
), or suggestions are not accepted on Enter
(config.editor.acceptSuggestionOnEnter == 'off'
).
- There are no multiple selections (
!editorHasMultipleSelections
).
- The extension doesn't interfere when using Vim (
vim.mode
not in certain modes like Normal, Visual, etc.).
By default, this keybinding is active only when these conditions are met.
Usage
Once installed, the extension will automatically manage list formatting when you press Enter
at the end of a list item in your Markdown file. Here's how it works:
1. Task Lists
- If you're working with task lists (e.g.,
- [ ]
or - [x]
), pressing Enter
will:
- Add a new task list item with an empty checkbox (
[ ]
).
- Move the checkbox in completed tasks (
[x]
) to the next line.
2. Ordered Lists
- If you're working with ordered lists (e.g.,
1.
, 2.
, 3.
), pressing Enter
will:
- Automatically add the next numbered list item, incrementing the number.
3. Unordered Lists
- If you're working with unordered lists (e.g.,
-
, *
, +
), pressing Enter
will:
- Automatically add the next unordered list item.
4. Blockquotes
- If you’re working with blockquotes (
>
), pressing Enter
will:
- Automatically continue the blockquote with the correct indentation.
Configuration
You can customize the behavior of the extension in two ways:
2. Using VSCode Settings GUI:
You can also configure the extension directly through the VSCode Settings GUI (Graphical User Interface):
- Open Settings by pressing
Ctrl + ,
(or Cmd + ,
on macOS).
- Search for
markdown.extension.numberedList.marker
.
- You will see an option labeled "Editor: Numbered List Marker". Set this option to
true
to auto-increment the numbers, or false
to start with 1
for each new item.
2. Using settings.json
:
You can edit your settings.json
file to configure the extension’s behavior. Here’s a setting to control the numbering behavior for ordered lists:
markdown.extension.numberedList.marker
: This setting controls whether the numbering is auto-incremented or set to 1
for each new item. Set this to true
to auto-increment list numbers, or false
to always start at 1
.
Example:
{
"markdown.extension.numberedList.marker": true
}
Contributing
If you would like to contribute to this extension, feel free to fork the repository and submit pull requests. Be sure to write tests for any new features or bug fixes!
License
This project is licensed under the MIT License - see the LICENSE file for details.