gpt4 book ai didi

vim - 在 Vim 中突出显示当前行的第 70 个字符

转载 作者:行者123 更新时间:2023-12-04 18:02:27 24 4
gpt4 key购买 nike

我喜欢尽可能保持严格的 70 个字符的边距。为了解决这个问题,我想配置 vim,以便突出显示当前行的第 70 个字符。我明白那个

set cursorline

可用于突出显示当前行。然而,我只想
要突出显示的行的末尾(第 70 个字符)。我将如何实现这一目标?

编辑: cursorcolumn 不是我要找的。我只想要一个字符(当前行的第 70 个字符)。

编辑 2:也许一张图片会有所帮助。 enter image description here

最佳答案

您可以使用 colorcolumn设置“右边距”栏。

这在 Vim 7.3 之前不存在,因此最好仅在该功能可用时启用它。

if exists('&colorcolumn')
set colorcolumn=70
endif

我更喜欢这仅在插入模式下显示,所以我使用这个:

if exists('&colorcolumn')
autocmd InsertEnter * set colorcolumn=80
autocmd InsertLeave * set colorcolumn=""
endif

这将在您切换到插入模式时设置该选项,并在您离开插入模式时将其关闭。

关于vim - 在 Vim 中突出显示当前行的第 70 个字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41927344/

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