David Mulder
David Mulder

Reputation: 8017

vim highlighting everything in red

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?

Upvotes: 7

Views: 12596

Answers (5)

HC2718
HC2718

Reputation: 81

For a quick fix, you might try typing:

:hi Error NONE

And then hit Enter.

Upvotes: 8

BrownRecluse
BrownRecluse

Reputation: 1670

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.

Upvotes: 3

Michael Ekoka
Michael Ekoka

Reputation: 20078

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>

Upvotes: 2

jathanism
jathanism

Reputation: 33706

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.

Upvotes: 10

Steven Rumbalski
Steven Rumbalski

Reputation: 45542

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 '''

Upvotes: 2

Related Questions