aboutsummaryrefslogtreecommitdiff
path: root/plugin/scroll_next.vim
blob: 8f09b2475fdc2234aba5539603cde0e6563ef7c0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"
" scroll_next.vim: Mapping to scroll a page forward until the buffer's end,
" and then to go to the :next buffer in the argument list.
"
" Author: Tom Ryder <tom@sanctum.geek.nz>
" License: Same as Vim itself
"
if exists('loaded_scroll_next') || &compatible
  finish
endif
if v:version < 600
  finish
endif
let loaded_scroll_next = 1

" Check visibility of last line (Vim >=7.0) or cursor presence on last line
" and flick to :next if appropriate, or just page forward with PageDown
function! s:ScrollNext() abort
  if line('.') == line('$')
        \ || line('w$') == line('$')
    silent! next
  else
    execute "normal! \<PageDown>"
  endif
endfunction

" Mapping setup
nnoremap <silent> <unique>
      \ <Plug>(ScrollNext)
      \ :<C-U>call <SID>ScrollNext()<CR>