From d1f74490f0475165a6744d9d01cbbb1862c182f6 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 31 Jul 2018 12:33:31 +1200 Subject: Add scroll_next.vim plugin --- vim/plugin/scroll_next.vim | 32 ++++++++++++++++++++++++++++++++ vim/vimrc | 5 +++-- 2 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 vim/plugin/scroll_next.vim (limited to 'vim') 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 +" 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! \" + endif +endfunction + +" Mapping setup +nnoremap + \ (ScrollNext) + \ :call ScrollNext() diff --git a/vim/vimrc b/vim/vimrc index 69b88998..a1f9b66f 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -184,8 +184,9 @@ imap (DigraphSearch) " Remap normal space to scroll down a page nnoremap -if v:version > 700 - nnoremap line('.') == line('$') ? ':next' : '' +" If we have plugins, do a :next after hitting the last line +if &loadplugins + nmap (ScrollNext) endif " Map g: as a 'colon operator' -- cgit v1.2.3