gpt4 book ai didi

scripting - 如何 : assign vim cursor to a certain line in the window and have the text scroll underneath that cursor position?

转载 作者:行者123 更新时间:2023-12-03 08:00:10 24 4
gpt4 key购买 nike

您可以将光标线保持在屏幕中间,然后通过将 scrolloff 设置为一个非常大的数字来让文本在其下方滚动。前任:

:let &scrolloff = 999

要阅读有关其工作原理的更多信息:
:help scrolloff

我喜欢这个功能并一直使用它,但我希望能够将光标保持在屏幕中间以外的其他位置。例如,我希望能够将光标保持在窗口顶部并让文件在其下方滚动。我很确定vim本身没有任何东西可以做到这一点,所以我想知道是否有人想出了一个轻量级的vim脚本片段来做到这一点(或者有人可以想出这样的脚本)?

这是我的小 .vimrc 帮助程序代码,用于快速切换光标的位置:
" SCROLLFIX SHORTCUTS
function! ToggleMyScrollFix()
if ( g:scrollfix == 5 )
let g:scrollfix = 50
elseif ( g:scrollfix == 50 )
let g:scrollfix = 95
elseif ( g:scrollfix == 95 )
let g:scrollfix = 5
else
let g:scrollfix = 50
endif
endfunction
nnoremap <silent> zz :call ToggleMyScrollFix()<CR>lh

最佳答案

查看 scrollfix plugin .我几年前使用过它,所以我不知道它是否仍然适用于 Vim 的最新快照——但最坏的情况是,它应该给你一个很好的开始修改它以适合你。

关于scripting - 如何 : assign vim cursor to a certain line in the window and have the text scroll underneath that cursor position?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1179529/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com