Tuesday, October 26, 2010

Behavior like 'scrolloff', but only for jumps?

When searching through files, I'd like to have "context" in the sense
that 'scrolloff' provides. But I don't want it for normal editing.

E.g. I'd like to be able to manually scroll such that the cursor is on
the last line of the window, but when jumping around via 'n', I don't
ever want to end up on the last line.

Is there such an option already?

If not, how could I simply wrap the built-in normal mode 'n' command
with a save-and-restore of 'so'?

First attempt: (guessing it fails because of calling feedkeys from w/in
a mapping?)

fun! NoEndJump()
let so=&l:so
call feedkeys('n','n')
let &l:so=so
endfun
nnoremap n <C-O>:call NoEndJump()<CR>

--
Best,
Ben

--
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

No comments:

Post a Comment