Saturday, December 28, 2013

Re: display the title of current fold in the statusline


On Dec 28, 2013 5:38 PM, "BimbaLaszlo" <bimba.laszlo@gmail.com> wrote:
>
> I have a custom statusline and i like to display the title of the fold where the cursor is in while i'm in insert mode.
>
> Here's my statusline:
>
> highlight link StatFname    StatusLine
> highlight link StatFenc     StatusLineNC
> highlight link StatPath     LineNr
> highlight link StatLnum     StatusLineNC
>
> highlight link StatFnameINS StatusLine
> highlight link StatFencINS  StatPath
> highlight link StatPathINS  StatPath
> highlight link StatLnumINS  StatPath
>
> highlight link StatFnameNC  StatusLineNC
> highlight link StatFencNC   StatFnameNC
> highlight link StatPathNC   StatFnameNC
> highlight link StatLnumNC   StatFnameNC
>
> let &statusline = "%!StatusLine( '' )"
> function StatusLine( mode )
>
>   let statusline  = '%#StatFname' . a:mode . '#'
>   let statusline .= '%w%t%r%m '
>
>   let statusline .= '%#StatFenc' . a:mode . '# '
>   let statusline .= '[' . (&binary ? 'binary' : (&fenc . (&bomb ? '-bom' : ''))) . ' ' . &ff . '] '
>
>   let statusline .= '%#StatPath' . a:mode . '# '
>   let statusline .= '%<'
>   if (a:mode == 'NC') || (a:mode == '') && (mode() == 'n')
>     let statusline .= expand("%:p:h") . (has("win32") ? '\' : '/')
>   else
>     let statusline .= 'TITLE OF FOLD'
>   endif
>
>   let statusline .= '%='
>
>   let statusline .= '%#StatLnum' . a:mode . '# '
>   let statusline .= '%3v | %5l/%L (%3p%%)'
>
>   return statusline
>
> endfunction
>
> autocmd  WinEnter,InsertLeave     *  let &l:statusline = "%!StatusLine( ''    )"
> autocmd  InsertEnter,InsertChange *  let &l:statusline = "%!StatusLine( 'INS' )"
> autocmd  WinLeave                 *  let &l:statusline = "%!StatusLine( 'NC'  )"
>
> I Googled and did :helpgrep to find the method without success.

There is a family of functions with names starting with fold. You need foldtextresult().

>
> --
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google Groups "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
 
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: