Disable Code Folding?



  • I read that Code Folding has a big impact on performance (https://community.notepad-plus-plus.org/topic/16808/why-is-notepad-so-slow-on-large-files-now/6)

    I’m working with a 40MB XML file. It takes minutes to open or save the file, and jumping to a line (CTRL-L), jumping to the end of file (CTRL-END), etc takes minutes.

    Is there any way to disable Code Folding? Not just hide the folding column but disable the feature entirely?

    The same file is quick to open, save and work with in Visual Studio, but VS is missing functionality that I have in Notepad++.

    I’m using Notepad++ 8.1 (x64 build)



  • Or perhaps there is something else I can do so Notepad++ will work reasonably with large files?



  • @Adrian-Parker ,

    To disable code folding, you can disable the whole lexer – so go to Language menu and select None (Normal Text) – but that gets rid of syntax highlighting as well as code folding.

    this discussion from a few days ago links to a plugin called “Big Files plugin”
    (https://github.com/superolmo/BigFiles), which also may be of help to you.



  • @PeterJones

    Sadly that plugin doesn’t work very well. It’s buggy (ALT down-arrow takes you multiple hits to get to the last line), and the line numbers presented are only valid for the current buffer and not for the entire file.

    For example my XML file has 5,518,743 lines. CTRL-G 5516147 takes me to the end of the current buffer (line 4,252).

    When I go to the end of the file (ALT down arrow, twice), it shows the final line number as 1,078.

    I may just use Visual Studio, I guess. It’s fairly fast with large files, and maintains the proper line number display.



  • @PeterJones

    Setting the Langauge to None must be done after opening the file though, and opening the file is part of the problem (it seems to take 10 minutes or more on a local file that is only 120 MB). I don’t have a super expensive drive, but it is an SSD.



  • @Adrian-Parker

    Change the extension to .txt then open the file. When you’re done and saved, rename back to .xml

    But as you’ve read in the older threads, Notepad++ wasn’t optimized for being a large-file editor; it was optimized for being a generic text editor with lots of features that make it useful for programming and using plugins to extend capabilities.



  • @PeterJones

    I had thought about changing the file extension previously, and tested it. A *.txt file containing XML is still opened by Notepad++ with code folding enabled (and is extremely slow to open)



  • @Adrian-Parker said in Disable Code Folding?:

    A *.txt file containing XML is still opened by Notepad++ with code folding enabled

    Sorry, I forgot that certain lexers have additional heuristics beyond file extension. I am out of ideas, sorry.



  • @PeterJones

    It’s ok. Thank you for the help.



  • @PeterJones said in Disable Code Folding?:

    @Adrian-Parker said in Disable Code Folding?:

    A *.txt file containing XML is still opened by Notepad++ with code folding enabled

    Sorry, I forgot that certain lexers have additional heuristics beyond file extension. I am out of ideas, sorry.

    @Adrian-Parker, I just created a tab in Notepad++ with XML content, no colour highlighting. Then I saved as a TXT file. Still no colour highlighting. As soon as I saved a copy as a XML file the lexer started and code folding and colour highlighting was enabled.

    However on the XML file I could set Language as “normal text” which as you know turns off those features. I reset back to language XML and I have “remember current sessions for next launch” ticked. So after I closed Notepad++ and re-opened the TXT file, it still was not coloured, the XML file was coloured. I then changed the XML file to language normal text. Closed Notepad++ and re-opened, it now is not coloured.

    So presumably the save session option together with tagging that XML file as “normal text” might allow it to stick and therefore not slow down the opening process.

    This was only a quick test and the idea may not lend itself to your needs (if you need to close and not remember files across launches).

    my 2c worth
    Terry



  • @Terry-R said in Disable Code Folding?:

    So presumably the save session option together with tagging that XML file as “normal text” might allow it to stick and therefore not slow down the opening process.

    Some other thoughts.

    Look at the session.xml file located (normally) under %appdata%\Notepad++ folder. It includes the following lang="None (Normal Text)", of course it could be any including XML for each file saved in a session that’s used for the next opening of Notepad++. Possibly you could open your XML file once (by itself) in a Notepad++ session, change language to normal text. Have the “save session for next launch” ticked. Close Notepad++ and then backup that session.xml file. Whenever you want to open this file (all by itself initially) swap the session.xml files. I haven’t tested this and I’d say it’s not what I would call normal practise.

    Another alternative is to run a portable Notepad++ environment and customise it so that it cannot run the XML lexer (is that possible?). I had a quick look and cannot identify a file called that. I see the lang.xml file refers to the extensions but changing that alone probably won’t prevent the XML lexer from working. I also looked at Preferences, Language and see an option to disable languages such as XML. The online manual here doesn’t elaborate enough to tell us what effect that has. Maybe another experienced forum member might know that answer.

    OR a combination of the above, using a portable Notepad++ environment with the session saved for next launch setting ticked and ONLY this XML file as the file to open with it set to language normal text. That way you don’t change lots of settings for “normal” editing.

    Cheers
    Terry



  • @Terry-R

    But I’m opening an existing 120 MB XML file. I’m not creating a new one.



  • @Terry-R said in Disable Code Folding?:

    Look at the session.xml file located (normally) under %appdata%\Notepad++ folder. It includes the following lang="None (Normal Text)", of course it could be any including XML for each file saved in a session that’s used for the next opening of Notepad++.

    So perhaps I can change that to be *.xml only. I’ll look into that.

    Possibly you could open your XML file once (by itself) in a Notepad++ session

    But that takes 10+ minutes.

    In Visual Studio the same file opens in about 5 seconds. It seems that Visual Studio automatically turns off XML features when opening large XML files (a warning in the Output window confirms this).

    It would be nice if Notepad++ would automatically disable language features if the file is over X many bytes.

    , change language to normal text. Have the “save session for next launch” ticked. Close Notepad++ and then backup that session.xml file. Whenever you want to open this file (all by itself initially) swap the session.xml files. I haven’t tested this and I’d say it’s not what I would call normal practise.

    I open several different files, I’m not often opening the same file repeatedly.


Log in to reply