This function calls a list of handlers until one returns true, indicating the event was handled. If no handler returns true, a default action is executed. Take for example, the following CloseScratch function. function! CloseScratch() if &buftype == "nofile" && &bufhidden == "hide" && !&swapfile bdelete return 1 endif return 0 endfunction Using RunHandlers I can now dynamically overload > to call this function (in normal mode), like so: Adding more handlers should be easy enough. In this case, CloseScratch is tried first, and if that fails DefaultEsc is called.
| Attributes | Values |
|---|
| rdfs:label
| - Overload a key with multiple handlers
|
| rdfs:comment
| - This function calls a list of handlers until one returns true, indicating the event was handled. If no handler returns true, a default action is executed. Take for example, the following CloseScratch function. function! CloseScratch() if &buftype == "nofile" && &bufhidden == "hide" && !&swapfile bdelete return 1 endif return 0 endfunction Using RunHandlers I can now dynamically overload <esc></esc> to call this function (in normal mode), like so: Adding more handlers should be easy enough. In this case, CloseScratch is tried first, and if that fails DefaultEsc is called.
|
| Version
| |
| dbkwik:vim/property/wikiPageUsesTemplate
| |
| Previous
| |
| Category
| |
| Author
| |
| Subpage
| |
| Complexity
| |
| Created
| |
| ID
| |
| NEXT
| |
| abstract
| - This function calls a list of handlers until one returns true, indicating the event was handled. If no handler returns true, a default action is executed. Take for example, the following CloseScratch function. function! CloseScratch() if &buftype == "nofile" && &bufhidden == "hide" && !&swapfile bdelete return 1 endif return 0 endfunction Using RunHandlers I can now dynamically overload <esc></esc> to call this function (in normal mode), like so: " Default Escape and clear message line. function! DefaultEsc() normal! "" echo "" endfunction let g:esc_handler = [] call add(g:esc_handler, "CloseScratch") nnoremap :call RunHandlers(g:esc_handler, "call DefaultEsc()") Adding more handlers should be easy enough. In this case, CloseScratch is tried first, and if that fails DefaultEsc is called.
|