Vim 80 character line in specific files

不想你离开。 提交于 2019-12-11 08:22:30

问题


I've recently started to use Vim. I set 80 character line in .vimrc, using follow command:

set colorcolumn=80

But this line is displayed not in all files. Look at screenshots below:

My .vimrc is here. Does anybody know, what problem is?


回答1:


You have the following lines scattered within your vimrc:

" higlight column right after max textwidth
set colorcolumn=+1

" Disable vertical line at max string length in NERDTree
autocmd FileType * setlocal colorcolumn=+1
autocmd FileType nerdtree setlocal colorcolumn=""

set colorcolumn=80

Also relevant is the fact that you have not apparently set 'textwidth' to anything, so it should be at its default value of zero, and from the vim help on 'colorcolumn':

When 'textwidth' is zero then the items with '-' and '+' are not used.

So, what I suspect is happening is that the autocommand with * as the wildcard is running and setting colorcolumn=+1, which is basically disabling it, since 'textwidth' is zero.

Thus, you can solve the problem by either ensuring 'textwidth' is set, or removing the autocommand. And, more generally, you should clean up your various settings of 'colorcolumn' within your vimrc to not negate / interfere with one another.



来源:https://stackoverflow.com/questions/29308215/vim-80-character-line-in-specific-files

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