开发者

vim highlighting everything in red

开发者 https://www.devze.com 2023-03-08 04:40 出处:网络
I added a print line to a python script while the script was executing, and now all the text is highlighted in red when I 开发者_如何转开发open the file. Opening and closing the file doesn\'t get rid

I added a print line to a python script while the script was executing, and now all the text is highlighted in red when I 开发者_如何转开发open the file. Opening and closing the file doesn't get rid of it. Opening a second python file momentarily fixed the problem, but then closing file and reopening brought the problem back. Now it wont go away at all. Any body know what could cause this?


This happens sometimes in vim when it goes to highlight syntax on multi-line comments. Occasionally everything after the multi-line comment also becomes colored the same as the comment.

I am unsure whether this is a legit bug in vim, or in the actual syntax settings for Python (e.g. python.vim), but I definitely experience this from time-to-time.


For a quick fix, you might try typing:

:hi Error NONE

And then hit Enter.


Old thread, but hope this helps.

By mistake I did a "/." on my vim screen, which highlighted all lines in red. If I open any other file, the red highlighting stays.

Try searching for some other keyword, let's say "/word" - doesn't matter word exists or not. It restores the color.


You probably have an unterminated multiline string. They start and end with either three single or three double quotes.

''' <== this is the start of a multiline string



this is still in the string
this is the last line '''


As per this article http://vim.wikia.com/wiki/Fix_syntax_highlighting, I mapped F12 to resync the syntax highlighting from the start of the file. It has worked better in some instances where <ctrl-l> didn't.

noremap <F12> <Esc>:syntax sync fromstart<CR>
inoremap <F12> <C-o>:syntax sync fromstart<CR>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号