Enabling syntax and syntax folding in vim with large C file makes completion slow

前端 未结 2 404
情话喂你
情话喂你 2021-01-05 19:59

When I have syntax on in a large C file (about 8000) lines the completion ctrl-p and ctrl-n are very slow (more than 20). When I turn syntax off then completion takes less t

相关标签:
2条回答
  • 2021-01-05 20:23

    Vim is sometimes slow to (especially for ins-completion) in large files due to foldmethod=syntax

    From :help todo:

    • Slow combination of folding and PHP syntax highlighting. Script to reproduce it. Caused by "syntax sync fromstart" in combination with patch 7.2.274. (Christian Brabandt, 2010 May 27) Generally, folding with 'foldmethod' set to "syntax" is slow. Do profiling to find out why.

    The FastFold plugin makes it so folds are only recalculated on save (so you're always using foldmethod=manual -- but the folds are calculated with foldmethod=syntax or whatever you had set before).

    This solved the problem for me. Now I can use compl-whole-line completion in my 5000 line C++ file and it's instant and snappy instead of taking minutes and unresponsive.

    0 讨论(0)
  • 2021-01-05 20:35

    I'm guessing your completion is being adjusted by the syntax highlighting file. To see if this is the case, and make completion lean and fast regardless, try

    :set complete=.
    

    which will make completion only use the current file.

    read more about the complete options with

    :help 'complete'
    
    0 讨论(0)
提交回复
热议问题