NotepadNext: A cross-platform reimplementation of Notepad++
github.com
github.com
Meanwhile if I use Notepad++ and load the same file windows shows it is using 586MB.
Any ideas why such high memory usage if this is a direct port to QT?
~2x memory looks like a naive implementation of just allocating an std::string from heap for each line. Due to heap fragmentation and various overhead it would quickly blow up.
~1x memory looks like just reading the entire file into RAM (that would still be slow).
A truly efficient implementation would never need to load the entire original file in RAM. It would just need to remember the binary offset of each line in a way that combines random access and reasonably fast insertion/deletion (e.g. K-fold trees). You can even keep everything beyond the top-level directory in an temporary on-disk file, so your RAM usage could be less than 1MB with nearly instant performance.
The efficient implementation is tricky, error-prone, and involves handling a solid amount of corner cases, which is beyond the amount of hassle a typical hobbyist developer is willing to go through.
Except that this would most likely result in unpredictable corruption if another process modified the file while you had it open, which is contrary to the way basically every text editor works.
It would be nice if there was a way to mmap a file in such a way that the OS would give you a snapshot view, but AFAIK that doesn't exist, at least on Linux in a filesystem-agnostic way (not sure about other operating systems).
On Windows in particular you also have a ton of other facilities that could help with this (opportunistic locks, transactions, etc.) but notification is usually good enough.
My text editor supports files up to 256 GB in size, unless you have that much memory, you’ll have to wait a little bit to go from the first to the last line.
It is a lot more performant than VS Code, but VS Code seems to have won on the sheer quantity of “good enough” plugins. Its pair programming features are a big deal as well.
For the most part I use VIM for quick things and VS Code when I need a plugin or to work with others. SBT kinda sits between those two extremes.
The pair programming feature from VSC is the only one I’d really miss from that side if I were to go back to SBT. Not sure about from the VIM side because I’m sure the SBT VIM plugins have improved over the past 8 years.
To know the offset of each line, you'll need to load the entire file from disk. So you're talking about loading it, processing it, and throwing it out again. You should qualify calling that "efficient" since you will need to re-load portions of the file, as needed.
Also, an OS's virtual memory systems may work well for you with minor tuning, so it's work looking into that before you spend a lot of time essentially writing your own.
I think unless you have a good reason not to, your best bet for a text editor on a modern OS is to read the entire file into memory and leave it there. (But don't make multiple copies of it or use two bytes to store each character as the current version of NotepadNext is apparently doing.)
No. You will need to read the file, not load it all at once in memory. And for a sequential scan, you need very little memory at any one time.
And if you are doing that, you can start displaying the file as soon as you have scanned enough to fill the view. The rest could happen in the background.
The problem with that for a text editor is that probably the first thing you want to do is process the line endings. So you’re just going to access the entire file, right away, as fast as possible anyway.
So mapping doesn’t really give an advantage in this case.
I think this is mostly likely the culprit. There almost definitely isn't that much contiguous memory available for a large file like this, so there are a lot of wasted pages (maybe 2-3x) which is causing that footprint to balloon.
We wouldn't use large quantities of RAM today if there were any techniques that could make disk acces "nearly instant".
I think I'd be a bit unhappy if I was regularly loading megabyte blobs of text into editors, and start looking at other representations or tools.
The only files that big that I know of are log files, and very occasionally a CSV or two as some kind of data dump, and there's usually dedicated tools for those cases.
It's worth keeping in mind that typical CPUs from the past few years to today have memory bandwidths of several GB/s. Disks have sequential read speeds of ~100MB/s; SSDs can easily do 1GB/s and above.
Vim's implementation also feels somewhat line-oriented in that if you load a large JSON file that has everything on 1 line and you try to edit that line, uh... it will be sluggish, but if you do, like %!jq '.' and format it, you can them move around the file a little easier.
Edit - What the heck while I'm at it:
Emacs - Historically used a Gap-Buffer which optimized more for locality of edits than loading large files. It doesn't suffer though as much from heap fragmentation though as the linked-list of strings type approach.
Monaco - The editor in VS Code recently went from a linked-list of strings to a PieceTree buffer. Which basically loads a the whole file into an immutable buffer and then uses the PieceTree to manage the edits.
Others - Lately people keep talking about Ropes, which is another tree type deal with extra-smarts specifically for text editing. I don't know of a game-changing editor like the others mentioned that uses it tho.
An example for an editor that uses them to manage large text files is Xi-Editor: https://github.com/xi-editor/xi-editor (edit: written in Rust).
Looks more line Qt's internal UTF-16 encoding in this case.
Is there any open source text editor doing this?
One downside, relative to this conversation, is it doesn't make working with pathologically large files a lot better. Without further optimization a gap buffer could push your box into swap if you open a large enough file.
It's frustrating but users don't understand how to read memory usage at all. There's even guides out there quite wrongly telling users to look at virtual memory usage for each app.
Mmap is a brilliant way to have the os handle which parts of the file actually reside in memory but you'll seriously have to deal with users that know only enough to be dangerous complaining that your app uses gb of ram when it's merely mapping a file into virtual address space to allow the os to page as it sees fit.
In fact I wouldn't at all be surprised if the memory measurements in this thread were judging virtual allocation rather than physical memory used.
I could think of a reasonable implementation for Linux that would use mmap and fallocate, but it wouldn't "just" be an mmap, as the swap file would still need to represent a rope or a gap buffer or something else of the sort for efficient editing.
Sure, I didn't mean to imply that the whole document would be one giant QString. But those data structures might still use a QString as backing memory in the new implementation. I tried to have a look around, but didn't have too much time on hand to dive deep. I could see some QString usage but couldn't confirm if the document itself uses it for storage.
> Wouldn't Notepad++ use UTF-16 internally too, with its Windows heritage
Not necessarily, as the memory consumption of 586MB for a 500MB file shows.
Definitely my goto editor for non-code files. I've wondered if emacs can do the same, but when I've asked an emacs user responded with "Why would you want to open 800 files?" I take that as a "no"?
Emacs handles it fine. Two years ago¹, I wrote this:
“Just last week I opened, edited, and saved, a 4 Gigabyte SQL dump file, in Emacs. It was a bit slower than usual, but still well usable, and certainly no crashes.”
Emacs users aren't accustomed to getting questions they don't know the answer to, IMHO.
As for Linux, Pluma[1] is great too.
They seem to add a lot of features, though ... I'd be interested to find a more minimal one, which mostly just updates language syntaxes and OS support, and the thankless minor bug squashing ...
> Title: uBlock filters – Badware risks
> Description: For sites documented to put users at risk of installing adware/crapware etc. The purpose is to at least ensure a user is warned of the risks ahead.
(I amended the URL)
The pace of the development, including just reacting to issues or PRs is rather slow.
Basic editing functions are few (just compare the contents of the "Edit" submenu with Notepad++). This is partially mitigated by "Send selection to", but a text editor without a simple line sorting?..
The settings for the "Build" submenu is artificially limited. Why just 3 filetype and 3 shared commands? Why not allow changing the keyboard shortcuts for those right in the same window?
No macro or scripting at all. In my view, such programs benefit a lot from having all their actions available as a list of commands which can be used to construct custom chains and scripts or be used setting the keybindings.
Somehow, not all the lexers from lexilla are available? For example, Nim lexer is more than 3 years old (5, if you count lexer for an earlier version then called Nimrod), but Nim settings for Geany still uses the Python lexer.
For sorting I do in fact use the "Send selection to" to sort, bound to Ctrl+1, but I never got around to binding anything to Ctrl+2.
There were tons of little fiddly things in Notepad++ I never used because the things they fixed they never came up often enough to build up muscle memory to remember them. YMMV.
You could also just run it in a browser window with a VNC HTML bridge, this would be a good base for that: https://github.com/accetto/ubuntu-vnc-xfce-g3
The easiest way to get Chicago95 setup is to run its GUI installer python script. I don't try to script it in a dockerfile or container setup.
This also goes for terminal-based editors, BTW. The old RHIDE is in many ways still unsurpassed in the intuitiveness and inherent extensibility of its text-based interface. A modern *nix-based equivalent would find plenty of use for light development work over SSH. (You could even ssh in and develop from an Apple iPad with keyboard addon!)
EDIT: It seems the font/underscore/spaces issues should be fixed as of Geany verion 1.37: https://www.geany.org/documentation/faq/#geany-does-not-disp...
I'm not using Geany much at all any more, but still got love for it!
I have geany open right now and it is displaying underscores just fine with Noto Sans Mono. I have no idea what configuration you were using or what fonts, but this shouldn't be a problem currently.
I had the issue with the Flatpak version in an unmodified install on Fedora Silverblue 35, but my experience is apparently hardly unique.
[styling]
line_height=0;2;
I recommend Source Code Pro which is a great programming font and apparently doesn't have the problem, since I've never actually seen it.This has been a bug for years after they closed the issue and as far as I am aware they are the only software to have ever had a problem with these supposedly out of spec fonts that are still the default on some popular distributions.
I remember npp having a GUI, but from memory it was old-school, in the clunky sense and not in the simple one. It didn't have a little window showing code with the updates for example.
Now that you bring it up, that's an area where a developer could make a helpful contribution.
For Windows, how does this differ from Don Ho's original version? https://notepad-plus-plus.org/
What is the vision/goal of this fork? The README is minimal.
It seems like someone thought "building a Notepad++ of my own seems like a nice idea" and went with it long enough for it to become quite a competent editor.
Though the application overall is stable and usable, it should not be considered safe for critically important work.
There are numerous bugs and half working implementations. Pull requests are greatly appreciated.I am curious how this new editor compares to NQQ since both are Qt based spiritual derivatives of N++.
A comparison would be nice indeed.
The record and play macro feature is probably the most useful tool, I keep grabbing code from VStudio/JetBrains-based editors to refactor/format it in NP++. For me the future of text editors should go in the automated direction: "see these identifiers and strings, tabulate them in columns to make my code more readable, now convert this column of strings into identifiers with given prefix and camel case, and define them in that module."
In my job I often have clients install it so that we can review their datafiles and diagnose load problems. Many of my calls sound like this.
(On Zoom)
Me: Okay, so I understand this file is not loading, can you show me the file?
Client: (opens file)
Me: Ok, hard to see what's wrong at a glance. Can you open the file in Notepad++ for me?
Client: (Reopens file in N++)
Me: Ah, here we go. You see those characters in blue on line 49? Those are non-ASCII characters. You've got some garbage in there. NULLs, control characters, or some other thing. Those will break the XML parser. Try removing them and reloading the file.
Or:
Me: So it looks like this is coming from your source system with no line endings, and is quite difficult to read. Can you download the plug-in XML Tools/JSON Tools/Poor Man's TSQL Formatter and let's see if we can get the files indented to make reviewing easier?
Or:
Me: So if you click on the "View" tab and show the line-endings...thank you. This file is coming over with Windows CRLF line endings instead of the expected LF endings on UNIX/Linux. It's probably throwing off the record parser by one byte for each row. You can use the tool under 'EDIT' to change the newlines to UNIX convention, and you should be good to go.
Small things like that. It's a heck of a lot easier to teach the client to do that rather than try to convince them to run dos2unix on a terminal.
It's a handy thing to have on Windows for anything text-oriented. Having a dual-platform version would be a benefit as well, as probably 95% of Notepad++ users are comfortable on Linux as well, so it would be helpful to talk somebody through it over the phone without having to access the dusty recesses of their memory.
ed can do just that, and more!
It's mainly a preference thing.
Where did you get that impression?
I've been using VSCode for this, especially since it saves buffers without me having to save to a file and would love one with this feature.
I use VS Code for development but Sublime handles large files much better (large JSONs, log files, etc) and loads much faster than VSC does.
It’s free by default with lots of great extra features that can be unlocked with a purchase.
Maybe take a look at https://github.com/macvim-dev/macvim on mac, perhaps someone can comment about the state of macvim?
- Kate
- CudaText
- Sublime Text
- BBEdithttps://kate-editor.org/post/2022/2022-03-31-kate-ate-kwrite...
I don't know which one is better, however, Kate or Notepad++...
Opinions?
Wasn't that always the case?
Kate is awesome!!!
Also the directory navigation in the file dialog is clunky. The directory places are windows based rather than Linux based.
(And then someone could probably look at building Notepad++ in Roblox to ensure that it can be used in Linux :-))
The thing about games is that there's only a limited OS surface area that they'll usually touch. There's I/O, GPU, a single render Windows, audio, and input state, but when those core APIs work, games should run just fine. Boring Win32 software can get real dependent on some obscure system APIs, COM+ objects with certain properties, library loading behaviour, etc., all things that can be a challenge to emulate successfully without tripping up programs that assume certain APIs just never fail or return certain results. Games don't call APIs like DsRoleGetPrimaryDomainInformation or SHEnumerateUnreadMailAccountsW so projects like Proton don't usually add a lot of fixes in that space.
[0] Being real: I'll probably just run Npp in WINE
Most of the other features I use most are fairly common though: line sorting and dedupe, column editing, regex search and replace, EoL conversion, compare/diff, etc.
But if we think about IDEs, things aren't quite as rosy and I would love to see something as good as Visual Studio running on MacOS (the existing version is just a renamed Mono Develop).
I started learning vim but can't use it at work as I'm stuck on windows (which vim is rubbish on), and the way they (IT dept) installed it basically made it worse, so I never used it enough for it to be my go-to.
Anyway, I was going to say gVim is lovely on windows, with a little customization and doesn't require admin privileges (though it will likely be contrary to your companies IT policy to side-load it). Other alternatives are using vim emulation in VSCode or one of the Jetbrains editors (probably the strongest candidate for vim emulation: IdeaVim).
At least it was for me, Using Notepad++ for editing config files, batch files, large sql stuff from time to time and the occasional binary. Including search and replace in a bunch of directories.
Notepad++ is different.
Not having Notepad++ on MacOS is a major pain point for me.
Notably Notepad++ is not project/folder based. It is for editing a file.
Damn, sublime is what I use as my light weight editor ha. Never had trouble opening (relatively) large files.
Notepad++ has what you need to edit a file and not much else, but it also has a decent plugin system.
I looked and it turns out that Notepad++ does have the ability to open a folder as a workspace. So it's an extra option if it is needed.
So simple to put a complex macro together -- I had one today that removed empty lines, did a regex replace, then a straight text replace and some random line manipulation within 2 minutes. You can do it so often and quickly it's basically zero cost.
The point I'm making is that there are lines to be crossed and if you don't understand that you have simply taken a hard stance on some aspect of this.
That all being said, YES I totally agree the dev should have full rights to say that in his software - but we can have an opinion too.
Conversation is pointless as OP has now responded saying he simply doesn't like hearing about sex.
To use a hypothetical example - a cereal company puts some tasteless comment in an unobtrusive corner of the box. You don't have to look at it if you don't want to - you can turn the box, or put the cereal into another container, or just not read the box that closely. But why would you want to when there are 45 other brands of cereal on the supermarket shelf?
> GitHub is my Tinder, to flirt with developers, by using the romantic source code poetry.
I don't think he gaf whether people are offended by the word "sex".
And if you look at the things he's covered, he seems to be a good person.
Side note: Remember winamps start audio?
And yes, I do avoid companies with outspoken political views that I disagree with, especially if their actions tangibly harm other people.
P.s. Just one of the relevant reddit threads https://www.reddit.com/r/sysadmin/comments/2ubv7w/notepad_je...
It works like advertisement for ideology
Imagine you are installing Chrome and the installer shows a banner saying: we support Trump, Biden, Ukraine, Russia, China, invading Iraq... You might then feel uncomfortable using/contributing to software that has nothing to do with politics, because of a developer founded/random/misguided opinion
So when you go to download the newest version of one of your fav text editors and you’re faced with messages like “you guys support who I support in the war right?! You should because the other guy is crazy! I stand with this side, I’m literally changing the world!” and I just gotta sigh and roll my eyes. Sir this is an Arby’s.
https://github.com/notepad-plus-plus/notepad-plus-plus/pull/...
You're choosing not to. However I do agree, that is idiotic text to include.
This is something else.
Marshall Herff Applewhite Jr.