Can't edit title without opening fold in Vim
Suppose you have a cursor in a closed fold like in the picture.
alt text http://dl.getdropbox.com/u/175564/foldEdit.png
How can you edit the SMALLAPPS header without opening a fold in Vim?
a source to share
Do you want to edit the first line of a folded block, or the line that appears when the fold is closed? If it's the first one, I don't think you can do it without opening the fold. If it's the latter, look at the foldtext parameter . It can be any expression. This expression is evaluated to create this string.
From the docs:
'foldtext' is a string parameter that specifies an expression. This expression evaluates to get the text displayed for the closed fold. Example:
:set foldtext=v:folddashes.substitute(getline(v:foldstart),'/\\*\\\|\\*/\\\|{{{\\d\\=','','g')
This shows the first line of the fold, with "/", "/" and "{{{" removed. Note the use of backslashes to avoid some characters being interpreted by the ": set" command. It's easier to define a function and call this:
:set foldtext=MyFoldText() :function MyFoldText() : let line = getline(v:foldstart) : let sub = substitute(line, '/\*\|\*/\|{{{\d\=', '', 'g') : return v:folddashes . sub :endfunction
An alternative is the marking method. With it, you can enter any line before the drop marker and it will appear when the fold is closed.
From the docs:
Markers in the text tell you where the folds start and end. This allows you to pinpoint folds precisely. This will allow you to delete and fold, without the risk of including incorrect lines. The "Foldtext" option is usually set so that the text before the marker appears in a collapsed line. This allows you to enter the name into the fold.
Markers can include a level, or they can use matching pairs. By making the level easier, you don't need to add and avoid problems with mismatched marker pairs. Example:
/* global variables {{{1 */ int varA, varB;
a source to share