sponsor Vim development Vim logo Vim Book Ad

ttoc : A regexp-based table of contents of the current buffer

 script karma  Rating 880/220, Downloaded by 4565  Comments, bugs, improvements  Vim wiki

created by
Tom Link
 
script type
utility
 
description
This plugin tries to duplicate the functionality of Marc Weber's
outline.vim (vimscript #1947) on the basis of its description and of
vim's own |:g|. Other than outline.vim, it relies on tlib
(vimscript #1863).

The TToC[!] command can be used to get a quick table of contents of the
buffer based on a given regular expression. The regexp can be defined on
the command line, in window (w:ttoc_rx), buffer-local (b:ttoc_rx)
variables or in global filetype-specific (g:ttoc_rx_{&filetype})
variables. The order actually is: [wbg]:ttoc_rx_{&filetype} >
[wbg]:ttoc_rx.

In the list view, you can select a line and either preview it (<c-p>),
jump there (<), close the list and jump there (<cr>).

Example:

  " Use the default settings for the current file-type
  :TToC
  " Show all words beginning at column 1
  :TToC ^\w
  " Show 'if' statements (but not the concluding 'then' statement)
  :TToC ^\s*if\>.\{-}\ze\s\+then
  " Show 'if' statements and 3 extra lines
  :3TToC! \<if\>

TToC only shows the matching string. TToC! works somewhat like |:g| in
showing the whole line, only that you can browse/filter the list and
select an item after reviewing the results.
 
install details
Edit the vba file and type: >

    :so %

See :help vimball for details. If you have difficulties, please make
sure, you have the current version of vimball (vimscript #1502)
installed.

This script requires tlib (vimscript #1863) to be installed.

Suggested maps (to be set in ~/.vimrc): >
    noremap  <Leader>cc       :TToC<cr>
    inoremap <Leader>cc       <c-o>:TToC<cr>
    noremap  <Leader>c<space> :TToC!
    inoremap <Leader>c<space> <c-o>:TToC!

The following gives you a |[I| or |]I| like experience but with a IMHO more
convenient UI:

    noremap  <Leader>c#       :TToC! <c-r><c-w><cr>
    inoremap <Leader>c#       <c-o>:TToC! <c-r><c-w><cr>


Also available via git
http://github.com/tomtom/ttoc_vim
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
ttoc.vba 0.08 2013-11-15 7.0 Tom Link - Help template
- g:ttoc#scratch#wipeout defaults to: 'BufDelete,BufWipeout' . (&hidden ? '' : ',BufHidden')
- ttoc#View(): Use a clean filename
MD5 checksum: fcdca87eb2d549e516705e781cfaa069
ttoc.vba 0.07 2013-10-18 7.0 Tom Link - addon-info
- g:ttoc_rx_help
- Allow for g:ttoc_world_{&filetype}
- When deleting the source buffer, delete the respective ttoc buffer
MD5 checksum: bb3b38c08da5d2a5a852d4da75508e3f
ttoc.vba 0.06 2012-01-21 7.0 Tom Link - .gitignore
- Removed obsolete code
- \n triggers multiline mode (fixes https://github.com/tomtom/tlib_vim/issues/12)>- Markdown support
MD5 checksum: 87b122db88d0af8092f8b284ec64a9e9
ttoc.vba.gz 0.5 2009-10-11 7.0 Tom Link - Handle multi-line regexps (thanks to M Weber for pointing this out)
- Changed key for "trace cursor" from <c-t> to <c-insert>.
- Require tlib 0.32
- Fill location list
ttoc.vba.gz 0.3 2008-11-23 7.0 Tom Link - Highlight the search term on partial searches
- Defined :Ttoc as synonym for :TToC
- Defined :Ttocbg to open a toc in the "background" (leave the focus/cursor in the main window)
- Require tlib 0.21
- Experimental: ttoc#Autoword(onoff): automatically show lines containing the word under the cursor; must be enabled for each buffer.
- Split plugin into (autoload|plugin)/ttoc.vim
- Follow/trace cursor functionality (toggled with <c-t>): instantly preview the line under cursor.
- Restore original position when using preview
ttoc.vba.gz 0.2 2007-11-05 7.0 Tom Link - <c-e> Run a command on selected lines.
- g:ttoc_world can be a normal dictionary.
- Use tlib#input#ListD() instead of tlib#input#ListW().
- Require tlib >= 0.14
ttoc.vba.gz 0.1 2007-09-08 7.0 Tom Link Initial upload
ip used for rating: 142.132.191.50

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github