" Vim script to work like "less" " Maintainer: Bram Moolenaar " Last Change: 2004 Feb 19 " Avoid loading this file twice, allow the user to define his own script. if exists("loaded_less") finish endif let loaded_less = 1 " If not reading from stdin, skip files that can't be read. " Exit if there is no file at all. if argc() > 0 let s:i = 0 while 1 if filereadable(argv(s:i)) if s:i != 0 sleep 3 endif break endif if isdirectory(argv(s:i)) echomsg "Skipping directory " . argv(s:i) elseif getftime(argv(s:i)) < 0 echomsg "Skipping non-existing file " . argv(s:i) else echomsg "Skipping unreadable file " . argv(s:i) endif echo "\n" let s:i = s:i + 1 if s:i == argc() quit endif next endwhile endif set nocp syntax on set so=0 set hlsearch set incsearch nohlsearch " Don't remember file names and positions set viminfo= set nows " Inhibit screen updates while searching let s:lz = &lz set lz " Used after each command: put cursor at end and display position if &wrap noremap L L0:redraw:file au VimEnter * normal! L0 else noremap L Lg0:redraw:file au VimEnter * normal! Lg0 endif " When reading from stdin don't consider the file modified. au VimEnter * set nomod " Can't modify the text set noma " Give help noremap h :call Help() map H h fun! s:Help() echo " One page forward b One page backward" echo "d Half a page forward u Half a page backward" echo " One line forward k One line backward" echo "G End of file g Start of file" echo "N% percentage in file" echo "\n" echo "/pattern Search for pattern ?pattern Search backward for pattern" echo "n next pattern match N Previous pattern match" echo "\n" echo ":n Next file :p Previous file" echo "\n" echo "q Quit v Edit file" let i = input("Hit Enter to continue") endfun " Scroll one page forward noremap