outliner
A table-of-contents sidebar for markdown and LaTeX files in Vim.
Written in Vimscript. Needs Vim 8.1 or newer and nothing else.
Install*outliner-install*
Plug 'cegme/outliner'
With Vim 8 packages and no plugin manager:
git clone https://github.com/cegme/outliner.git \
~/.vim/pack/plugins/start/outliner
Open a .md or .tex file. The outline appears on the left and the cursor stays in your text.
Use*outliner-use*
- <Leader>ot
- Show or hide the outline.
- <Leader>of
- Move the cursor into the outline, and back to the text.
Inside the outline:
- Enter
- Jump to the header. A double-click does the same.
- r
- Refresh the outline.
- q
- Close it.
- ?
- List the keys in use.
The outline refreshes when you save. It follows the file you are editing and closes when that file is closed. :q in the text window exits Vim instead of leaving the outline alone.
:bd.Markdown and LaTeX*outliner-languages*
Markdown headers from # to ###### are listed, and fenced code is skipped. In LaTeX, \part through \subsubsection are listed, and comments and verbatim blocks are skipped. A header is indented under the closest earlier header with a smaller level.
# Introduction ## Getting Started ### Prerequisites ### Installation ## Usage # Other stuff
\section{Introduction}
\subsection{Getting Started}
\subsubsection{Prerequisites}
\subsubsection{Installation}
\subsection{Usage}
\section{Other stuff}
Both give this outline:
Introduction
Getting Started
Prerequisites
Installation
Usage
Other stuff
LaTeX header commands*outliner-latex*
Class files and slide decks use different sectioning commands. g:outliner_tex_headers maps a command name to a level. Entries merge over the defaults, only the order of the levels matters, and a level of 0 hides a command.
" Beamer slides
let g:outliner_tex_headers = {'frametitle': 4}
" A command from your class file, and run-in paragraph headings
let g:outliner_tex_headers = {'mysection': 3, 'paragraph': 6}
" Hide \part in a book
let g:outliner_tex_headers = {'part': 0}
\paragraph and \subparagraph are off by default. Many papers use them for run-in labels such as "Goal." and "Procedure.", which would crowd the outline.
g:outliner_tex_headers and refreshing.Settings*outliner-settings*
Put these in your .vimrc.
- g:outliner_width
- Sidebar width in columns. Default 20.
- g:outliner_position
'left'or'right'. Default'left'.- g:outliner_auto_open
- Open the outline when a supported file is entered. Default 1.
- g:outliner_focus
- Put the cursor in the outline when it opens. Default 0, so the cursor stays in the text.
- g:outliner_filetypes
- Filetypes that get an outline. Default
['markdown', 'tex', 'plaintex']. - g:outliner_tex_headers
- LaTeX command names and levels, described above.
- g:outliner_mappings
- Replace the keys inside the outline, for example
{'jump': ['<CR>', 'o']}. - g:outliner_no_mappings
- Set to 1 to skip the default
<Leader>keys. Map<Plug>(outliner-toggle)and<Plug>(outliner-focus)yourself.