Changing background color in vim at a certain column

做~自己de王妃 提交于 2019-11-30 01:45:06

Try this:

:match ErrorMsg '\%>80v.\+'

It will highlight text beyond 80 characters, you can replace '80' with whatever wrap-width you have. However, it will only highlight the characters that exceed the width, and then only on lines that are actually longer than the width.

Check http://vim.wikia.com/wiki/Highlight_long_lines for more info, but they all pretty much accomplish the same thing.

Since Vim 7.3 it's possible to have columns highlighted like this:

To set it to the current textwidth:

:set cc=+1

Or you can set it to predefined value:

:set cc=80

You can change its color like this:

:hi ColorColumn ctermbg=lightgrey guibg=lightgrey

See help for more details:

:help colorcolumn
autocmd FileType * execute "setlocal colorcolumn=" . join(range(&textwidth,250), ',')
highlight ColorColumn guibg=#303030 ctermbg=0

Big problem with this is that the colorcolumn highlighting has higher priority then hlsearch! So basically you wont be able to see highlighted search items beyond that margin...

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!