Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@ Try `:help concealcursor` and `:help conceallevel` for details.
:let g:vim_markdown_folding_level = 1
:edit

### Only recognize Atx headers

- `g:vim_markdown_atx_only`

To cause vim_markdown to only recognize Atx-style markdown headers during movement commands, add the following line to your `.vimrc`:

let g:vim_markdown_atx_only = 1

### Disable Default Key Mappings

- `g:vim_markdown_no_default_key_mappings`
Expand Down
31 changes: 22 additions & 9 deletions ftplugin/markdown.vim
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,34 @@

" For each level, contains the regexp that matches at that level only.
"
let s:levelRegexpDict = {
\ 1: '\v^(#[^#]@=|.+\n\=+$)',
\ 2: '\v^(##[^#]@=|.+\n-+$)',
\ 3: '\v^###[^#]@=',
\ 4: '\v^####[^#]@=',
\ 5: '\v^#####[^#]@=',
\ 6: '\v^######[^#]@='
\ }

" Maches any header level of any type.
"
" This could be deduced from `s:levelRegexpDict`, but it is more
" efficient to have a single regexp for this.
"
let s:headersRegexp = '\v^(#|.+\n(\=+|-+)$)'
let s:vim_markdown_atx_only = get(g:, "vim_markdown_atx_only", 0)
if s:vim_markdown_atx_only == 1
let s:headersRegexp = '^#'
let s:levelRegexpDict = {
\ 1: '\v^#[^#]@=',
\ 2: '\v^##[^#]@=',
\ 3: '\v^###[^#]@=',
\ 4: '\v^####[^#]@=',
\ 5: '\v^#####[^#]@=',
\ 6: '\v^######[^#]@='
\ }
else
let s:headersRegexp = '\v^(#|.+\n(\=+|-+)$)'
let s:levelRegexpDict = {
\ 1: '\v^(#[^#]@=|.+\n\=+$)',
\ 2: '\v^(##[^#]@=|.+\n-+$)',
\ 3: '\v^###[^#]@=',
\ 4: '\v^####[^#]@=',
\ 5: '\v^#####[^#]@=',
\ 6: '\v^######[^#]@='
\ }
endif

" Returns the line number of the first header before `line`, called the
" current header.
Expand Down