4

Reading the manual with ':help z' shows a variety of commands which can redraw the window, e.g. z.to redraw with the cursor in the centre or zb to redraw with it at the bottom of the screen.

zt is nice but I would find it much more comfortable to be able to redraw with the cursor 25% of the way down the page (so that what I was just writing is still visible). Is there an easier way to accomplish this other than macro-ing it?

General Grievance
  • 4,555
  • 31
  • 31
  • 45
Benjamin Gorman
  • 360
  • 1
  • 11
  • 2
    Not sure whether this is what you're looking for, but you can use `set scrolloff=n` (where n is some number of lines) to keep a specified number of lines always visible above the cursor at the top and bottom of the screen. – Brendan Ritchie Nov 13 '14 at 18:04

3 Answers3

5

You can use the 'scrolloff' option:

set scrolloff=4

See :help 'scrolloff'.

romainl
  • 186,200
  • 21
  • 280
  • 313
1

Here's the mapping (assigned to <Leader>zt) I use to put a number of lines above the cursor line at the top of the window:

nnoremap <silent> <Leader>zt :<C-u>exec 'normal! ' . v:count . 'kzt' . v:count . 'j'<CR>

If you don't supply a prefix, it will put the line above the cursor at the top of the window.

echristopherson
  • 6,974
  • 2
  • 21
  • 31
0

Regarding @echristopherson 's answer, this mapping should work, too:

nnoremap zt zt3<C-y>

and for the default behaviour:

nnoremap zT zt " 3<C-y> is not applied because of the n`nore` map.
Yosh
  • 2,512
  • 3
  • 24
  • 30