所以我讀:help scroll-cursor
,真的很喜歡zz
,它把你的光標在你的窗口中間。滾動Vim相對於光標,自定義映射
我正在尋找幫助來製作類似於zz
的貼圖,但將光標放在窗口高度的20%(或25%,30%等)上。
編輯:
感謝ZYX和Drasill,我能修改他的功能,以獲得所需的功能:
function ScrollToPercent(percent)
let movelines=winheight(0)*a:percent/100
if has("float") && type(movelines)==type(0.0)
let movelines=float2nr(movelines)
endif
let oldso=&so
execute ":set so=" . movelines
execute "normal! zt"
execute ":set so=" . oldso
endfunction
感謝您的示例,但此功能只移動光標,而不是光標和光標下方的行。查看我的上述編輯以獲得最終結果。 – 2010-06-23 17:54:30
@Nick Canzoneri剛剛在寫這篇評論時正在更新我的功能。 – ZyX 2010-06-23 17:55:29