idvorkin / Vim-Keybindings-For-Onenote

Replicate the vim keybindings in OneNote.
117 stars 18 forks source link

Single key binding for fold/unfold #7

Closed mofhu closed 8 years ago

mofhu commented 8 years ago

Hi all,

Thanks for your great work! I'm very happy to use this script in my onenote.

As I'm familiar with as a single key for folding/unfolding in Vim.

" press space to fold/unfold code
nnoremap <space> za
vnoremap <space> zf

I'm trying to add the key binding in autohotkey. I'm getting it done using a one-two press implementation: press once to fold; press twice to unfold (see the source below).

space::
Send, !+- ; send fold if no action
if IsLastKey("space")
{
send, !+{+}  ; double space to unfold block
}
return 

I'm wondering if we can detect fold status in onenote by autohotkey (so I may use single to control folding), is it possible? Any other advice will be appreciated.

Best,

Frank

idvorkin commented 8 years ago

Glad you're finding this script useful. In case you didn't see it, or for others skimming this issues, zo and zc are already mapped to fold open and fold close.

For detecting fold status - AutoHotKey can't easily figure out what state OneNote is in, so my advice is don't bother.

If you want to spend a bunch of time on this :) , technically you could use COM Automation to figure out the state of the OneNote page, but this would be HARD.

mofhu commented 8 years ago

Igor, Thank you for your kind reply. zo and zc work very well in my hand. I'll try to find out a easier setting for me to fold/unfold (as I'm not using zo/zc etc. in Vim, it may be a little complicate at first).