Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how vim map two command

Tags:

vim

I am wondering how to use one hotkey mapping two command in vim. for exmpale, I already have those two mapping

map <silent> <F7> zM
map <silent> <F8> zR

But, I just want to use F8 to toggle between zM and zR. Hoping anyone can give me solution. Thanks a lot.

like image 813
randomness2077 Avatar asked May 08 '26 15:05

randomness2077


1 Answers

Won't zA do what you wanted...?

If it won't then we need to go deeper. http://www.vim.org/scripts/script.php?script_id=1494 tells you what to do, here's the relevant script:

map <buffer> F8 :call ToggleFold()<CR> 
let b:folded = 1 
function! ToggleFold() 
  if( b:folded == 0 ) 
      exec "normal! zM" 
      let b:folded = 1 
  else 
      exec "normal! zR" 
      let b:folded = 0 
  endif 
endfunction 
like image 130
chx Avatar answered May 11 '26 15:05

chx