Question

Is it possible to open and close folds in Gvim using mouse clicks ?

Say double click opens and closes folds ?

Was it helpful?

Solution 2

This was what I was looking for

:noremap <2-LeftMouse> za

Toggles folds with mouse double click

Or may be triple click to avoid conflicting with text selecting command of vim

:noremap <3-LeftMouse> za

OTHER TIPS

In the fold column (e.g. :set foldcolumn=4), you can open / close folds by (single-)clicking on the signs; this works out-of-the-box.

I use a mapping similar to the one in your answer that just opens folds, but otherwise maintains the default doubleclick behavior:

" <2-LeftMouse>     Open fold, or select word or % match.
nnoremap <expr> <2-LeftMouse> foldclosed(line('.')) == -1 ? "\<2-LeftMouse>" : 'zo'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top