GARY FURASH wrote:
Is there an easy way to say "make line N" (e.g., 502) the top line of the
visual screen?




        502z+

This is a Normal-mode command, not an Ex-command. It also places the cursor on the first non-blank in the line, so if you have set 'scrolloff' to something else than its default of 0 there will be that many lines above line N (except if N <= &scrolloff). If that is not acceptable:

        function RedrawAtTop(line)
                let l = a:line + &scrolloff
                if l > line("$")
                        let l = line("$")
                endif
                exe "normal" l . "z+"
        endfunction
        command -nargs=0 -range -bar AtTop call RedrawAtTop(<line1>)

Invoke it then as

        :502AtTop

Just ":AtTop" will move the cursor line to the top, and move the cursor down by 'scrolloff' lines to allow the previous cursor line to be at top.



Best regards,
Tony.

Reply via email to