Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have defined a function in vim to properly indent folds. Ie so they look like this:

Unfolded

this is text 
also text
    indented text
    indented text
not indented text

folded with default function

this is text 
also text
+-- 2 lines: indented text ----------------------------
not indented text

folded with my new function

this is text 
also text
    ++- 2 lines: indented text ----------------------------
not indented text

The only problem is the the highlighting is still like this:

folded with my new function (highlighting shown with tag)

this is text 
also text
<hi>    ++- 2 lines: indented text ----------------------------</hi>
not indented text

I would like the highlighting to start at the ++ and not at the beginning of the line. I have looked in the vim manual but could not find anything like that. One so-so solution I found was to make the background black.

highlight Folded ctermbg=black ctermfg=white cterm=bold

But this make folds less visible.

I have tried several variations of:

syn keyword Folded lines
syn region Folded ...

But I don't think that this is the way that folds are selected. Can anyone offer a suggestion?

By the way this is my function to indent the folds:

set foldmethod=indent

function! MyFoldText()
        let lines = 1 + v:foldend - v:foldstart
        let ind = indent(v:foldstart)

        let spaces = ''
        let i = 0
        while i < ind
                let i = i+1
                let spaces = spaces . ' '
        endwhile

        let linestxt = 'lines'
        if lines == 1
                linestxt = 'line'
        endif

        return spaces . '+' . v:folddashes . ' '. lines . ' ' . linestxt . ': ' . getline(v:foldstaendfunction
endfunction


au BufWinEnter,BufRead,BufNewFile * set foldtext=MyFoldText()

By the way thanks to njd for helping me get this function setup.

share|improve this question
    
This would probably be answered quicker on stackoverflow.com – nathan Mar 10 '10 at 18:34
    
Thanks I cross posted it to here: stackoverflow.com/questions/2425522/….. Should I close/delete this thread now or leave it open? – sixtyfootersdude Mar 11 '10 at 14:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .