diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2018-07-31 12:33:31 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2018-07-31 12:35:07 +1200 |
commit | d1f74490f0475165a6744d9d01cbbb1862c182f6 (patch) | |
tree | aea7f57ef321cc12367fdf0b676b8855e13d8558 /vim/plugin | |
parent | Don't set up 'wildignore' in &compatible mode (diff) | |
download | dotfiles-d1f74490f0475165a6744d9d01cbbb1862c182f6.tar.gz dotfiles-d1f74490f0475165a6744d9d01cbbb1862c182f6.zip |
Add scroll_next.vim plugin
Diffstat (limited to 'vim/plugin')
-rw-r--r-- | vim/plugin/scroll_next.vim | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/vim/plugin/scroll_next.vim b/vim/plugin/scroll_next.vim new file mode 100644 index 00000000..fa33044e --- /dev/null +++ b/vim/plugin/scroll_next.vim @@ -0,0 +1,32 @@ +" +" scroll_next.vim: Mapping to scroll a page forward with CTRL-F until the last +" line is visible in the buffer (if supported) or the cursor is on the last +" line, and to run :next instead if so to move to the next buffer in the +" argument list. +" +" Author: Tom Ryder <tom@sanctum.geek.nz> +" License: Same as Vim itself +" +if exists('g:loaded_scroll_next') || &compatible + finish +endif +if v:version < 600 + finish +endif +let g: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 CTRL-F +function! s:ScrollNext() abort + if line('.') == line('$') + \ || line('w$') == line('$') + silent! next + else + execute "normal! \<C-F>" + endif +endfunction + +" Mapping setup +nnoremap <silent> <unique> + \ <Plug>(ScrollNext) + \ :<C-U>call <SID>ScrollNext()<CR> |