VimFold4C
VimFold4C copied to clipboard
Folds for c++11 range-based for loops and c++11 list initialization
Following example source code
#include <iostream>
#include <vector>
int main()
{
std::vector<int> v = {0, 1, 2, 3, 4, 5};
for (const int& i : v)
{
std::cout << i << ' ';
}
for (auto& c : google::GetLoggingDirectories()) {
std::clog << c << "\n";
}
}
has following folds
and folds to

My issues are
- I would not expect that a single line will be folded (line 6). With the following blank line the fold is actually two lines long. I know that
:set foldminlines=3removes this fold. - The fold text for range-based folds and the initialization list is trimmed more than necessary.
The values of g:fold_options in my vimrc are
let g:fold_options = {
\ 'show_if_and_else': 1,
\ 'strip_template_argurments': 1,
\ 'strip_namespaces': 1,
\ 'fold_blank': 0,
\ 'max_foldline_length': 'tw',
\ }
The single line is actually not that single. It's merged with the next line which is empty.
In order to ignore such cases, I should take fold_blank into account, which I don't.
Regarding the trimming of for range-loops, there was bug that should be fixed now -- the range was discarded. Still, I avoid to make to distinctions between the kind of lines before trimming them. I could of course ignore loops and such, but that'll mean another option.