sponsor Vim development Vim logo Vim Book Ad

EightHeader : Easily create custom (fold)headers, foldtext, toc, etc.

 script karma  Rating 0/0, Downloaded by 105    Comments, bugs, improvements  Vim wiki

created by
Laszlo Bimba
 
script type
utility
 
description
To use EightHeader just move the cursor to the line which you want to modify (hereinafter line), then call it:

EightHeader( length, align, oneline, pattern, marker, str )

length   Length of the header.
align    Alignment of text.
oneline  line and marker in one line, pattern in another.
pattern  Pattern to fill with.
marker   Extra content after patternRightEnd.
str      Replace the content of line with this.

An example with oneline:

call EightHeader( 78, "center", 1, ["l ", "pat", " r"], " m", "\\=' '.s:str.' '" )

l patpatpatpatpatpatpatpat TEXT IN THE LINE patpatpatpatpatpatpatpat r m

... and whitout it:

call EightHeader( 78, "center", 0, ["l ", "pat", " r"], " m", "" )

                              TEXT IN THE LINE                         m
l patpatpatpatpatpatpatpatpatpatpatpatpatpatpatpatpatpatpatpatpatpatpa r

If you don't like the default 'foldtext' you can customize it by setting to
EightHeaderFolds().

For example the closed folds looks like this by default:

+-- 45 lines: Fold level one
+--- 67 lines: Fold level two

If you would like to change it to this kind:

Fold level one................45 lines
  Fold level two..............67 lines

... then you can use this function:

let &foldtext = "EightHeaderFolds( '\\=s:fullwidth-2', 'left', [ repeat( '  ', v:foldlevel - 1 ), '.', '' ], '\\= s:foldlines . \" lines\"', '' )"

An alternative usage for example formating a vimhelp table of contents:

Options;options
Default mappings;maps
  Launch nuclear strike;apocalypse

... to this:

Options........................................................|options|
Default mappings..................................................|maps|
  Launch nuclear strike.....................................|apocalypse|

Visually select the lines, than:

call EightHeader( 78, "left", 1, ".", "\\='|'.matchstr(s:str, ';\\@<=.*').'|'", "\\=matchstr(s:str, '.*;\\@=')" )
 
install details
Open in vim then run
:so %

... or use Vundle:

Add these lines to your .vimrc after 'call vundle#rc()':

Plugin 'bimbalaszlo/vim-eightheader'

Open vim again, then call ':PluginInstall'

Please rate if you using it!
 

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
eightheader.vmb 1.0 2014-05-16 7.4 Laszlo Bimba Moved to github.
eightheader.vmb 1.0 2014-05-15 7.4 Laszlo Bimba "Please rate" advertisement.
eightheader.vmb 1.0 2014-04-30 7.4 Laszlo Bimba Help about comment handling.
eightheader.vmb 1.0 2014-04-30 7.4 Laszlo Bimba Previous vimballs was broken, sorry.
Added more help.
ip used for rating: 54.198.130.203

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.
   
SourceForge.net Logo