The following work on normal and visual modes:
- - `]]`: go to next header.
- - `[[`: go to previous header. Contrast with `]c`.
- - `][`: go to next sibling header if any.
- - `[]`: go to previous sibling header if any.
- - `]c`: go to Current header.
- - `]u`: go to parent header (Up).
+ - `]]`: go to next header. `<Plug>(Markdown_MoveToNextHeader)`
+ - `[[`: go to previous header. Contrast with `]c`. `<Plug>(Markdown_MoveToPreviousHeader)`
+ - `][`: go to next sibling header if any. `<Plug>(Markdown_MoveToNextSiblingHeader)`
+ - `[]`: go to previous sibling header if any. `<Plug>(Markdown_MoveToPreviousSiblingHeader)`
+ - `]c`: go to Current header. `<Plug>(Markdown_MoveToCurHeader)`
+ - `]u`: go to parent header (Up). `<Plug>(Markdown_MoveToParentHeader)`
+## Commands
+
+The following commands currently only work for atx style headers (`#`). Pull request are welcome to extend them to Setext style headers (`===`).
+
+- `:Toc`: create a quickfix vertical window navigable table of contents with the headers.
+
+ Hit `<Enter>` on a line to jump to the corresponding line of the markdown file.
+
+- `:Toch`: Same as `:Toc` but in an horizontal window.
+- `:Toct`: Same as `:Toc` but in a new tab.
+- `:Tocv`: Same as `:Toc` for symmetry with `:Toch` and `Tocv`.
+
## Credits
The main contributors of vim-markdown are:
execute 'vn <buffer><silent> ' . a:rhs . ' <esc>:call <sid>VisMove(''' . a:lhs . ''')<cr>'
endfunction
- call <sid>MapNormVis(']]', 'b:Markdown_MoveToNextHeader')
- call <sid>MapNormVis('[[', 'b:Markdown_MoveToPreviousHeader')
- call <sid>MapNormVis('][', 'b:Markdown_MoveToNextSiblingHeader')
- call <sid>MapNormVis('[]', 'b:Markdown_MoveToPreviousSiblingHeader')
+
+ call <sid>MapNormVis('<Plug>(Markdown_MoveToNextHeader)', 'b:Markdown_MoveToNextHeader')
+ call <sid>MapNormVis('<Plug>(Markdown_MoveToPreviousHeader)', 'b:Markdown_MoveToPreviousHeader')
+ call <sid>MapNormVis('<Plug>(Markdown_MoveToNextSiblingHeader)', 'b:Markdown_MoveToNextSiblingHeader')
+ call <sid>MapNormVis('<Plug>(Markdown_MoveToPreviousSiblingHeader)', 'b:Markdown_MoveToPreviousSiblingHeader')
" Menmonic: Up
- call <sid>MapNormVis(']u', 'b:Markdown_MoveToParentHeader')
+ call <sid>MapNormVis('<Plug>(Markdown_MoveToParentHeader)', 'b:Markdown_MoveToParentHeader')
" Menmonic: Current
- call <sid>MapNormVis(']c', 'b:Markdown_MoveToCurHeader')
+ call <sid>MapNormVis('<Plug>(Markdown_MoveToCurHeader)', 'b:Markdown_MoveToCurHeader')
+
+ if ! exists('g:markdown_no_default_key_mappings')
+ \ || !g:markdown_no_default_key_mappings
+ nmap ]] <Plug>(Markdown_MoveToNextHeader)
+ nmap [[ <Plug>(Markdown_MoveToPreviousHeader)
+ nmap ][ <Plug>(Markdown_MoveToNextSiblingHeader)
+ nmap [] <Plug>(Markdown_MoveToPreviousSiblingHeader)
+ nmap ]u <Plug>(Markdown_MoveToParentHeader)
+ nmap ]c <Plug>(Markdown_MoveToCurHeader)
+
+ vmap ]] <Plug>(Markdown_MoveToNextHeader)
+ vmap [[ <Plug>(Markdown_MoveToPreviousHeader)
+ vmap ][ <Plug>(Markdown_MoveToNextSiblingHeader)
+ vmap [] <Plug>(Markdown_MoveToPreviousSiblingHeader)
+ vmap ]u <Plug>(Markdown_MoveToParentHeader)
+ vmap ]c <Plug>(Markdown_MoveToCurHeader)
+ endif
+
+command! -buffer Toc call b:Markdown_Toc()
+command! -buffer Toch call b:Markdown_Toc('horizontal')
+command! -buffer Tocv call b:Markdown_Toc('vertical')
+command! -buffer Toct call b:Markdown_Toc('tab')