Calvin Waterbury asked on Sunday, October 01, 2006 3:00 PM about
an "Outline" feature:
> The "Outline" feature is mainly intended to produce a much
> larger work, like a book**. The format that is in my present
> editor has a "gutter" on the side which has listed the headings
> of the "chapters." The active text ed window only displays the
> contents of the heading selected.
One way would be via folds but this won't have the "gutter" (see
the file "notes.vim" below).
The exact feature (with "gutter") can be implemented with some
VimL scripting.
> I realize and know how I can implement a work-around, but if
> this is available or can be created, then it would be desirable.
What is your work-around?
--Suresh
"Here's my $VIM/vimfiles/ftplugin/notes.vim file:
if exists("b:did_ftplugin")
finish
endif
let b:did_ftplugin = 1 " Don't load another plugin for this buffer
"mapping to underline
"nmap <buffer> <localleader>u $a:<esc>Yp$x^v$r-
nmap <buffer> <localleader>u Yp$x^v$r-
nmap <buffer> <F5> :syn off\|syn on<cr>
setlocal spell
setlocal smartindent
setlocal foldexpr=MyNotesFoldLevel(v:lnum)
setlocal foldmethod=expr
setlocal foldtext=getline(v:foldstart)
setlocal foldcolumn=0
setlocal fillchars=fold:\
if !exists("*s:MyNotesFoldLevel")
function! MyNotesFoldLevel(acline)
let cline = a:acline
let text = getline(cline)
"a blank line inherits its foldlevel
if(text =~ '^\s*$') | return '=' | endif
if(cline == 1) | return (indent(cline) + 1)/3 | endif
let textm1 = getline(cline-1)
"interior line of a para
if(textm1 !~ '^\s*$')
if(getline(cline+1) =~ '^\s*$') | return '=' | endif
" see if this line starts a hanging indent!
if(indent(cline) < indent(cline+1)) | return '>'.
((indent(cline)+1)/3) | endif
return '='
endif
"find the nearest non-blank line above
let i = 2
let textm = getline(cline-i)
while(textm =~ '^\s*$') " will always exit from while
let i = i + 1
let textm = getline(cline-i)
endwhile
"this line and preceding non-trivial line have different indents
if(indent(cline) != indent(cline-i)) | return '>'. ((indent(cline)+1)/3)
| endif
"preceding non-trivial line is single line para
let i = i + 1
let textm = getline(cline-i)
if(textm =~ '^\s*$') | return '>'. ((indent(cline)+1)/3) | endif
"this line starts a hanging indent
if(indent(cline) < indent(cline+1)) | return '>'. ((indent(cline)+1)/3)
| endif
"TODO: maybe preceding should be '>=' (after computing what = would
entail)
return '='
endfunction
endif
finish