Vim always ended up frozen on me when opening big XML files, one big verbose line each. Just had to delete my tmux session though, not restart everything.
It could be the syntax highlighting if you have that on; Vim loves to throw regexes to long lines to highlight them. Thankfully it stops at one point. I don't think treesitter using Neovim has this problem, I should test that.
I struggle to imagine how that could slow it down. In the end it shouldn't matter whether you have dozens of lines or one long wrapped line, it's still roughly the same number of tokens to parse/highlight. Though admittedly I haven't yet tried with syntax highlighting turned off to see if that's the issue.
I don’t know how the highlight engine is coded, but I do know that it’s regex based. You moslty have to try every regex on every line. And for some lines you have to try it more than once (think tags).
When it doesn’t match, it’s ok. When it does match you jave to create new structures, adjust their priorities. And for the renderer, every scrolling means reissuing the ansi excape code according to some theme.
All of this are probably bound to the number n of characters in a line. And for big n, that means a lot of operations. Emacs also struggle with long lines.
Regexes are line-based most of the time. And so the more characters you have on the line, the more work the engine has to do to parse it. I guess with greedy quantifiers you need to go to the end of the line and then match from there, and I don't think that's free. Multiply that by the crazy amount of regexes Vim native highlighting uses and the engine begins to struggle.
That being said, I didn't look at the code of the engine itself, so I don't know for sure. But I know that disabling the highlighting get rid of these kind of issues most of the time.
On one hand that makes sense, but the editor knows how much of the line can fit on screen and I don't see why it can't limit the regex to that plus remaining characters before the next whitespace. In theory this could maybe miss some really weird edge case tokens but in reality I don't think it matters.
For what it's worth, Vim is nowhere near as bad with long lines as typical GUI text editors in my experience (currently I have access to Xed and... yeah.)
Absolutely. I don't think I've seen a text editor not struggling with long lines, Vim being far from the worse. I don't think I tested Neovim with treesitter though.
I've been tinkering with my own editor on and off and getting its performance to be independent of line length was shockingly easy compared to my expectations based on other editors.
One possible difference is that my syntax highlighting code was only applied on the text that's actually shown on screen and not the entire line. It came with some limitations like multiline string highlighting being broken, but then again I didn't put in much effort to make it work well.
Vim always ended up frozen on me when opening big XML files, one big verbose line each. Just had to delete my tmux session though, not restart everything.
Replies (1)
Replies (2)
Replies (1)
Replies (2)
When it doesn’t match, it’s ok. When it does match you jave to create new structures, adjust their priorities. And for the renderer, every scrolling means reissuing the ansi excape code according to some theme.
All of this are probably bound to the number n of characters in a line. And for big n, that means a lot of operations. Emacs also struggle with long lines.
That being said, I didn't look at the code of the engine itself, so I don't know for sure. But I know that disabling the highlighting get rid of these kind of issues most of the time.
Replies (1)
Replies (1)
Replies (1)
One possible difference is that my syntax highlighting code was only applied on the text that's actually shown on screen and not the entire line. It came with some limitations like multiline string highlighting being broken, but then again I didn't put in much effort to make it work well.