Question

Is there any way in gvim to obtain a clickable code folding margin, similar to the one available in diff mode? Please refer the diff mode screenshots attached.

Note that I am comfortable using the keyboard commands for code folding, but sometimes clicking is more convenient.

I have searched on the internet and also here. I have only found material which explains the keyboard commands, but nothing about the clickable option.

Edit I use gvim version 7.0.

Screenshot demonstrating the clickable code-folding margin (not folded)Screenshot demonstrating the clickable code-folding margin (folded)

Was it helpful?

Solution

Assuming that folding has been set up for your filetype (i.e. you can use keyboard commands like za), you just need to enable the fold column with a specified width, e.g.:

:set foldcolumn=4

If you set this globally, it will always be there. If you only want to enable it for certain filetypes (that actually have folding), and/or adapt the width to the amount of nested folding, use :setlocal foldcolumn=... instead, and put the corresponding commands into ~/.vim/after/ftplugin/<filetype>.vim, where <filetype> is the actual filetype (e.g. java). (This requires that you have :filetype plugin on.)

Alternatively, you could define an :autocmd FileType <filetype> setlocal foldcolumn=... directly in your ~/.vimrc, but this tends to become unwieldy once you have many customizations.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top