On Fri, Feb 26, 2010 at 5:23 PM, Jean Johner <jean.joh...@cea.fr> wrote:
> On Feb 26, 6:58 pm, Ben Fritz <fritzophre...@gmail.com> wrote:
>
>> 2. Re-map CTRL-F/CTRL-B with an :nnoremap command that issues the
>> command, then scrolls by 1 line with CTRL-Y/CTRL-E in the correct
>> direction to get the desired amount of context.
>
> Hi Ben,
> CTRL-F CTRL-E does the job but the transition is visible on a slow
> connection (VPN).
> For CTRL-D, it is more complicated since it depends on the vertical
> dimension of the screen.
>
> It is nevertheless surprising that, in a code where everything can be
> configured, this two lines overlap between screens seems to be set in
> stone.

Perhaps make the map call a function that ensures 'lazyredraw' is set
while scrolling.  This seems to do the trick, afaics, and has no
noticeable delay over the slowest connection I can get.

~Matt

function! s:ScrollLeavingOneLineOffset(dir, insert)
  let savelz = &lz
  set lazyredraw

  try
    if a:dir > 0 && a:insert
      return "\<PageDown>\<C-o>\<C-e>"
    elseif a:dir > 0
      return "\<PageDown>\<C-e>"
    elseif a:insert
      return "\<PageUp>\<C-o>\<C-y>"
    else
      return "\<PageUp>\<C-y>"
    endif
  finally
    let &lz = savelz
  endtry
endfunction

noremap  <expr> <C-b>      <SID>ScrollLeavingOneLineOffset(-1, 0)
noremap  <expr> <PageUp>   <SID>ScrollLeavingOneLineOffset(-1, 0)
noremap  <expr> <C-f>      <SID>ScrollLeavingOneLineOffset( 1, 0)
noremap  <expr> <PageDown> <SID>ScrollLeavingOneLineOffset( 1, 0)

inoremap <expr> <C-b>      <SID>ScrollLeavingOneLineOffset(-1, 1)
inoremap <expr> <PageUp>   <SID>ScrollLeavingOneLineOffset(-1, 1)
inoremap <expr> <C-f>      <SID>ScrollLeavingOneLineOffset( 1, 1)
inoremap <expr> <PageDown> <SID>ScrollLeavingOneLineOffset( 1, 1)

-- 
You received this message from the "vim_use" 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

Reply via email to