开发者

vimscript get number of first and last visible line

开发者 https://www.devze.com 2023-03-09 10:31 出处:网络
I know I can go to the first and last visible line of current buffer with H and L respectively. But how I can pass the开发者_如何学Go line numbers to variables ?let topline = line(\"w0\")

I know I can go to the first and last visible line of current buffer with H and L respectively. But how I can pass the开发者_如何学Go line numbers to variables ?


let topline = line("w0")
let botline = line("w$")


There might be a better way, but if nothing else, you can use H and L to move there and `` to get back and get. Something like

norm 'H'
let top=line('.')
norm '``L'
let bottom=line('.')
norm '``'

or you can use getpos() to store and setpos() to restore the position, but I am not sure you can avoid destroying the previous position mark (the :keepmarks command should do that, but it's documentation says it only works in some special case).

0

精彩评论

暂无评论...
验证码 换一张
取 消