Am 11.03.2010 10:22, schrieb Jean Johner:
Hello,
Considering the answers to vim_use thread "Naive question: scrolling
down keeping only 1 line" posted on 26 February, it appears that the
offset when scrolling down (2 lines) is not configurable.
My preference is 1 line (as proposed by default by other text editors:
nedit, sedit ...)
I did not find acceptable simple solutions in vim:
- CTRL-F CRTL-E works but the transition between the 2 commands is
visible on slow connections
- (lines-2)CTRL-D does not work with mutiple windows
Could vim developpers consider one of the following:
- propose (or find) a script which works in all cases
- introduce an 'offset' option (or other name) in vim which could be
0, 1, 2, ...
It is clearly not an urgent task.
Thanks
Regards
Jean Johner
try this one:
function! <sid>ScrollWithOffset(dir, insert)
" {insert} currently not used
let cnt = v:count>=1 ? v:count : ""
if a:dir > 0
let scrollcmd = cnt."\<C-f>".cnt."\<C-e>"
else
let scrollcmd = cnt."\<C-b>".cnt."\<C-y>"
endif
let savelz = &lz
set lazyredraw
try
exec "normal!" scrollcmd
finally
let &lz = savelz
endtry
endfunction
noremap <SID>Scroll <C-\><C-n>:call <sid>ScrollWithOffset
" go to Normal mode first:
" - cancel an operator
" - abort Visual mode
" but: this skips the count
nnoremap <SID>Scroll :<C-u>call <sid>ScrollWithOffset
inoremap <SID>Scroll <C-o>:call <sid>ScrollWithOffset
noremap <silent><script> <C-b> <SID>Scroll(-1, 0)<CR>
noremap <silent><script> <PageUp> <SID>Scroll(-1, 0)<CR>
noremap <silent><script> <C-f> <SID>Scroll( 1, 0)<CR>
noremap <silent><script> <PageDown> <SID>Scroll( 1, 0)<CR>
inoremap <silent><script> <C-b> <SID>Scroll(-1, 1)<CR>
inoremap <silent><script> <PageUp> <SID>Scroll(-1, 1)<CR>
inoremap <silent><script> <C-f> <SID>Scroll( 1, 1)<CR>
inoremap <silent><script> <PageDown> <SID>Scroll( 1, 1)<CR>
" Notes:
" - Insert mode, the cursor position (column) isn't remembered. Maybe this
" has to do with :h todo
" 7 Setting an option always sets "w_set_curswant", while this is only
" required for a few options. Only do it for those options to avoid the
" side effect.
--
Andy
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php