Friday, January 22, 2010

Folding with 'cuddled' else

I vastly prefer 'cuddled' 'else':

if ($something) {
// do one thing
} else {
// do another
}

to 'uncuddled' 'else':

if ($something) {
// do one thing
}
else {
// do another
}

But, 'cuddled else' yields undesirable folding:

+-- 5 lines: if ($something) {-----------------

Whereas 'uncuddled else' gets me the more useful:

+-- 3 lines: if ($something) {-----------------
+-- 3 lines: else {----------------------------

( Ideally, I'd get: )
+-- 2 lines: if ($something) {-----------------
+-- 3 lines: } else {--------------------------

In addition to fdm=syntax, the following settings are possibly
applicable:

For Perl, I have:

let perl_fold = 1
let perl_fold_blocks = 1

and with PHP, I have:

let g:PHP_default_indenting = 1
let g:PHP_vintage_case_default_intent = 1
let php_folding = 2

Is there any way to do this with fdm=syntax, or do I have to switch to
fdm=expr?

--
Best,
Ben

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php

No comments: