6 months ago
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 else normal H endif endfunction nnoremap <C-l> :call ToggleHML()<CR>