2017-09-01 07:03:25 +08:00
---
title: "SpaceVim lang#markdown layer"
2017-12-07 23:19:13 +08:00
description: "Edit markdown within vim, autopreview markdown in the default browser, with this layer you can also format markdown file."
2017-09-01 07:03:25 +08:00
---
2018-06-23 14:37:41 +08:00
# [Available Layers](../../) >> lang#markdown
2017-09-01 07:03:25 +08:00
<!-- vim - markdown - toc GFM -->
2017-09-04 07:38:24 +08:00
2017-12-07 23:19:13 +08:00
- [Description ](#description )
2018-06-23 14:37:41 +08:00
- [Install ](#install )
2019-02-20 15:57:42 +08:00
- [Formatting ](#formatting )
2017-12-07 23:19:13 +08:00
- [options ](#options )
2020-08-01 10:51:28 +08:00
- [Tagbar ](#tagbar )
2017-12-07 23:19:13 +08:00
- [Key bindings ](#key-bindings )
2017-09-01 07:03:25 +08:00
<!-- vim - markdown - toc -->
## Description
2017-05-10 21:35:45 +08:00
This layer is for editing markdown file.
2018-06-23 14:37:41 +08:00
## Install
2017-09-01 07:03:25 +08:00
2018-06-23 14:37:41 +08:00
To use this configuration layer, update custom configuration file with:
```toml
[[layers]]
name = "lang#markdown"
```
2017-09-01 07:03:25 +08:00
2020-04-22 19:35:49 +08:00
The tagbar support is provided via lvht/tagbar-markdown which needs php has been installed. You can also use [mdctags ](https://github.com/wsdjeg/mdctags.rs )
which is written in rust.
2019-02-20 15:57:42 +08:00
## Formatting
2017-09-01 07:03:25 +08:00
2020-08-01 13:36:20 +08:00
SpaceVim uses remark to format Markdown file by default.
2019-02-20 15:57:42 +08:00
You can install remark via [npm ](https://www.npmjs.com/get-npm ), the commands are shown as below.
2019-03-10 20:49:12 +08:00
2017-09-01 07:03:25 +08:00
```sh
npm -g install remark
npm -g install remark-cli
npm -g install remark-stringify
2019-05-06 11:32:04 +08:00
npm -g install remark-frontmatter
npm -g install wcwidth
2017-09-01 07:03:25 +08:00
```
2017-05-10 21:35:45 +08:00
2020-08-01 13:36:20 +08:00
To use [Prettier ](https://github.com/prettier/prettier ),
you need to change the layer option: `enabled_formater` .
2019-02-20 15:57:42 +08:00
You can install [Prettier ](https://github.com/prettier/prettier ) via [yarn ](https://yarnpkg.com/lang/zh-hans/docs/install/#windows-stable ) or [npm ](https://www.npmjs.com/get-npm ), the commands are shown as below:
1. Via `yarn`
2019-03-10 20:49:12 +08:00
2019-02-20 15:57:42 +08:00
```sh
yarn global add prettier
```
2019-03-10 20:49:12 +08:00
2019-02-20 15:57:42 +08:00
2. Via `npm`
2019-03-10 20:49:12 +08:00
2019-02-20 15:57:42 +08:00
```sh
npm install --global prettier
```
2017-09-04 07:38:24 +08:00
### options
**listItemIndent**
How to indent the content from list items (`tab`, `mixed` or 1 , default: 1).
2017-09-06 07:45:39 +08:00
- `'tab'` : use tab stops (4 spaces)
- `'1'` : use one space
- `'mixed'` : use `1` for tight and `tab` for loose list items
2017-09-04 07:38:24 +08:00
**enableWcwidth**
2017-10-08 19:36:23 +08:00
Enable/Disable wcwidth for detecting the length of a table cell, default is 0. To enable this option, you need to install [wcwidth ](https://www.npmjs.com/package/wcwidth )
**listItemChar**
Bullet marker to use for list items (`'-'`, `'*'` , or `'+'` , default: `'-'` ).
2017-09-04 07:38:24 +08:00
2020-08-01 13:36:20 +08:00
**enabled_formater**
Specific the enabled formater for markdown file, default is `['remark']` .
2020-05-04 18:19:36 +08:00
## Tagbar
To have a table of the headings in the tagbar (toggled by [F2]), make sure php is in your `$PATH` (you can test this in SpaceVim : `:!php --version` should print something about php).
If you don't want to install php, you can use [mdctags ](https://github.com/wsdjeg/mdctags.rs ) as an alternative.
2017-09-01 07:03:25 +08:00
## Key bindings
2017-05-10 21:35:45 +08:00
2019-02-28 11:52:45 +08:00
| Key bindings | mode | Descriptions |
| ------------ | ------------- | ------------------------------------------------------ |
| `SPC b f` | Normal | Format current buffer |
| `SPC l k` | Normal/Visual | Add URL link for word under cursor or slected word |
2020-05-04 18:19:36 +08:00
| `SPC l K` | Normal/Visual | Add picture link for word under cursor or slected word |
2019-02-28 11:52:45 +08:00
| `SPC l p` | Normal | Real-time markdown preview |