CTRL-D Scroll window Downwards in the buffer. The number of
lines comes from the 'scroll' option (default: half a
screen). <b>If [count] given, first set 'scroll' option
to [count].</b> ...
Execute 1<ctrl-d> for one time, it will set 'scroll' to 1, you can then use <c-d> and &...
scroll the view of the bottom window without switching to that window
Something like this
call win_execute(win_getid(winnr('j')), "normal! \<C-E>")
winnr('j') returns Window number of a window below the current one. win_getid() translates Window number to :h winid. Then win_execute() runs an arbitrary command as if that window were active (...
Most likely the developer didn't feel that this feature is important enough to deserve a simple key. On the other hand it is possible to create mappings using 1<C-d> and 1<C-u> when you need it.
Remember that vi was initially implemented by Billy Joy in 1976. At that time scrolling the screen might have been an expensive operation.
Just stumbled across this question/answer, and I think it's a terrific idea, with an ingenious solution!
However, while I think the existing answer is very clever, something about it doesn't sit well with me. I don't like the fact that, while in one sense the disabling of 'virtualedit' is automatic, it's not fully automated: it relies on the user using one ...
Simply do this:
'sidescroll' controls "the minimal number of columns to scroll horizontally". So with a value of 1 h and l will shift the screen one column at a time.
Side note: the commands zh and zl will shift the screen a column at a time but they don't move the cursor. If, for some reason, you couldn't or didn't want to change ...
Assuming you have 2 windows. Then map like this in your .vimrc:
map <F11> <C-W><C-W><C-D><C-W><C-W>
It will map F11 to do these actions:
<C-W><C-W> - move cursor to second window.
<C-D> - scroll second window downwards half of screen.
<C-W><C-W> - move cursor back to first window.
For normal mode, rather than remapping scroll commands, I would use an autocommand:
autocmd CursorMoved * normal! zz
For insert mode, as you've discovered, simple autocommands won't suffice. Instead, note that there are very few keystrokes that can cause the cursor to change lines when in ...
This is essentially packing @Rich's solution (temporarily setting 'scrolloff') into a function, to improve readability.
I'm also defining a command and a mapping with a little bit more of flexibility (allowing a custom offset to be specified through a "count") and usability.
let save_scrolloff = &l:scrolloff
The brute force way to do it:
:let scrolloff_before = &scrolloff | set scrolloff=10 | redraw | let &scrolloff = scrolloff_before | unlet scrolloff_before
This works by saving the current 'scrolloff' value in a variable, setting it to 10, redrawing the screen so the update is applied (which is necessary because we are running all the commands in a ...
Orthogonally to my other answer, here's a version of SetVirtualEdit() that you can plug into your existing solution which does not require Python:
function! SetVirtualEdit() abort
let saved_view = winsaveview()
keepjumps normal! g0
let is_on_leftmost_screen = col('.') == 1