Giter Site home page Giter Site logo

tomtom / ttoc_vim Goto Github PK

View Code? Open in Web Editor NEW
8.0 3.0 2.0 157 KB

A regexp-based table of contents of the current buffer for vim

Home Page: http://www.vim.org/scripts/script.php?script_id=2014

Vim Script 100.00%
vim-script vim vim-plugin outline

ttoc_vim's Introduction

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.

The TToC command can also evaluate an expression to get the line 
numbers. The expression is evalutated if TToC is invoked without a regex 
argument and the expression is defined for that filetype 
([wbg]:ttoc_expr_{&filetype}). The expression needs to return either a 
sorted and unique list of line numbers either as a vim list or as a 
newline-separated string.

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\>

The TToC with a bang works somewhat like |:g| only that you can 
browse/filter the list and select an item after reviewing the results. 
Try it out and compare (with the help file as current buffer): >

  :TToC! TToC

with >

  :g/TToC



-----------------------------------------------------------------------

Status:  Works for me (there may be some minor quirks)
Dependencies:
  tlib :: http://github.com/tomtom/tlib_vim
      > git clone git://github.com/tomtom/tlib_vim.git
Install: See http://github.com/tomtom/vimtlib/blob/master/INSTALL.TXT
See http://github.com/tomtom for related plugins.

ttoc_vim's People

Contributors

idanarye avatar tomtom avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

idanarye nokobear

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.