emacs-evil / evil

The extensible vi layer for Emacs.
GNU General Public License v3.0
3.33k stars 282 forks source link

Evil mode word navigation too slow for large files #384

Open TheBB opened 10 years ago

TheBB commented 10 years ago

Originally reported by: Neeraj Sharma (Bitbucket: neerajsharma2, GitHub: Unknown)


Opening a large file say 8MB and try to skip words, by pressing w (or b) it takes a good couple of seconds in evil mode to jump to next word. When i go to emacs mode by pressing Ctrl-Z and do word navigation via Alt-f and Alt-b its instantaneous (infact even in normal mode if i press Alt-F and Alt-b its super fast)

The file is pure text file. I am using 64 bit emacs on windows but I have tried the 32 bit emacs as well (the stable release from gnu).

evil-version returns 1.0-dev


TheBB commented 10 years ago

Original comment by Frank Fischer (Bitbucket: lyro, GitHub: lyro):


Well that's right, but this is very difficult to solve.

The problem is that Evil motions are more complicate than standard Emacs motions. For instance, the word motions must differ between word and non-word characters as well as whitespace and empty lines. A single motion involves a lot more operations than the Emacs forward-word. And some of them are quite expensive: in order to make some regexp-based operations fast, Evil bounds the search to the beginning/end of the current line. But calling a simple function like end-of-line can take some time. I've just tested this on file 40MB file with all words on one (!) line, an the single function call took 15 seconds or so.

Maybe it is possible to implement everything more carefully, using only 'fast' functions, but it's definitely not easy (in fact, a single call to goto-char can take ages, and I'm not sure if this can be avoided at all).

DanielRichtmann commented 1 year ago

Using the latest master with the noverlay branch gave me a noticable speedup on evil movements and text objects in large files to an extent where they become actually usable again :)