3

Is there way to map e.g. F9 in .vimrc to toggle fold all/unfold all folds?

3

1 Answer 1

4

In your .vimrc file:

Use the following command to set your desired keystroke (change <C-F5> which is Ctrl+F5 to the combination you like):

noremap <C-F5> :call UnrolMe()<CR>

The function UnrolMe() toggles all unrolling (i.e. it subsequently calls zR and zM commands)

let $unrol=0
function UnrolMe()
if $unrol==0
    :exe "normal zR"
    let $unrol=1
else
    :exe "normal zM"
    let $unrol=0
endif
endfunction

Change zR and zM to the unrolling commands of your choice (see https://www.linux.com/learn/tutorials/442438-vim-tips-folding-fun for the list of commands). Hope this helps

1
  • Nice one, does the job!
    – Anthony
    Mar 7, 2016 at 13:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.