Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gvim fold toggle using mouse

Tags:

vim

folding

mouse

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

Say double click opens and closes folds ?

like image 545
Jean Avatar asked Dec 17 '12 23:12

Jean


Video Answer


2 Answers

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'
like image 147
Ingo Karkat Avatar answered Oct 19 '22 18:10

Ingo Karkat


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
like image 9
Jean Avatar answered Oct 19 '22 19:10

Jean