简体   繁体   中英

how vim map two command

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.

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 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM