For example, another ternary operator with map k:
nnoremap <expr> k (v:count == 0 ? 'gk' : 'k')
nnoremap <expr> j (v:count == 0 ? 'gj' : 'j')
When you go line down on a wrapped line, gk makes that you go to the next fictional line of a wrapped line. But when you do 5j, it will go 'over' the wrapped line. It worked fine.
In my case, I have mapped the zj to NextClosedFold() function.
But I thought it would be better, if I'm currently in a opened fold, and with zj, I could to the end of a opened fold, like ]z.
So I decided to create a map:
nnoremap <silent> sj (foldclosed('.') == -1 ? ]s : au call NextClosedFold('j')<cr>)
The :echo foldclosed('.')
will indicate if you're on a folded line or not. If youre not on a closed fold (-1), it will give ]s, but when this is not the case, it will move to the next closed fold. But the map is not working. I think it has something to do with the closing parenthesis, that Vim will interpret as closing the evaluation too early.
Any thoughts how to work around this?