Emacs like Ctrl-l - Function to jump among Top, Middle and Bottom of window

2 Points

On vim we have a normal mode keybinding "H" to jump to the top, "M" to jump to the middle and "L" to jump to the bottom of window, but in Emacs we have Ctrl-l that "Toggles" among these three states. This is my function and mapping to solve this issue.

" Emacs like Ctrl-l - jumpt to Middle, Bottom and Top of the window
function! ToggleHML()
    set scrolloff=0
    let l:last_win_line = ( line('$') <= winheight('%') ? line('$')  : winheight('%')  )
    if winline() < l:last_win_line / 2
      normal M
    elseif winline() < l:last_win_line
      normal L
      normal H
nnoremap <C-l> :call ToggleHML()<CR>