CodeMirror 6.0 Stable Release
marijnhaverbeke.nl
marijnhaverbeke.nl
The new editor in Obsidian was made possible by CodeMirror 6, and it has been powering both the Live Preview mode (like Typora) and the source mode in Obsidian ever since.
It can be a bit overwhelming to get into first, but as we experimented more with it, we found it to be extremely extensible and powerful. It's also highly performant for large documents. Another major reason we chose CM 6 is that it's also one of the only code editors that work decently on mobile.
While developing the new editor, Marijn was also amazingly responsive in investigating and fixing all the big and little things we ran into, even relatively niche issues like IME input bugs.
If you find CM 6 useful, consider what you can to support the project! Funding link is here: https://marijnhaverbeke.nl/fund/
We used to use d3-force for force simulation, but then we rewrote it in wasm ourselves for performance.
The nice thing is that the whole notebook is a single CodeMirror editor with cells stored as ranges in CodeMirror state. This way intercell actions like selection/copy/paste are possible and still you can control execution per cell.
Shortcuts at https://bqnpad.mechanize.systems/notebook
* Shift+Enter to eval cell
* Cmd-Enter to create new cell
* Cmd-Option-Enter to split cell at cursor
* Cmd-Backspace to join cell with the previous one
CM6 has a steep learning curve, in exchange for being even more flexible than 5. It's worth it.
It's exhausting to tailor language to the comments section. I once wrote a post called "the best programming font" and all the comments were about how it was not provably scientifically the best and it was just "my opinion." We're not writing math proofs here, let people express thoughts.
As some sort of reference, the most common (loved) editors are: neovim, vscode, rider, vim, emacs, intellij, ipython/jupyter, webstorm, pycharm, visual studio, rubymind, phpstorm, notepad++, xcode, sublime, android studio and so on.
Neither of those use CodeMirror.
https://insights.stackoverflow.com/survey/2021#most-loved-dr...
> Question: Which development environments did you use regularly over the past year, and which do you want to work with over the next year? Please check all that apply.
Yes, CodeMirror is big and popular, and great overall. Again, I'm not saying otherwise. It's just hard to take comments seriously when they are obviously not factual, and it detracts from the message you want to convey.
Edit: To be a bit more constructive: Instead of saying "CodeMirror is what everyone uses!" or "This font is the best font for programming!", try to write out the reasons of why you think like that instead, and let people arrive to their own conclusions. Describe the cases you've seen where CodeMirror shines, or write why and in what cases the font truly stands out to you. And maybe then you'll get a warmer reception in your replies.
Same as "Show, don't tell" among writers
If anyone is interested in the topic, the implementation is on Github: https://github.com/niklaskorz/puredit
Also, here's a demo: https://thesis.korz.tech/
Codemirror looks quite interesting!
On a unrelated note, this irks me slightly:
> CodeMirror 6 is a new code editor library for the web, a from-scratch implementation
Why not just call it something different at that point? It's essentially CodeMirrorNext v1, if everything has been reimplemented from scratch and all the API interface intentionally changed.
That way there won't be any confusion what editor API you talk about when you say "CodeMirror". Instead, we now have to ask follow up question "Version 6 or older though?".
This seems to happen in a large part of the ecosystem. React Router for example has gone through a lot of API churn, where basically the first three/four versions of React Router all look different, and should instead have been just three/four different libraries instead of versions.
Perhaps, but that's not new. IIRC all major version bumps of CodeMirror have essentially been full rewrites.
Increasing the version is a straightforward way to say “n is outdated, use n+1.” As a publisher I don’t want to start a new project with zero followers, especially if the project does the same exact thing my previous project did, just better.
Yeah, that's a good point and a lot of API interface churn we're seeing in the ecosystem makes sense to me now. People don't want to lose their social clout.
One could argue that that is exactly what happened in 2008, when the "sister language" meme was introduced. At that time, the Perl Porters basically abandoned all support for Perl 6 and started developing on Perl 5 again.
So development of Perl 6 basically fell back on just a handful of people, on the Parrot backend, which became less and less acceptable for Perl 6. And then people still wonder why it took so long?
Obsidian Live Preview is CM6 on desktop afaik?
A CM5 based editor is still available as "Legacy Editor" in the settings on desktop, to support older plugins.
Mobile was always using a CM6 editor, while desktop only got CM6 some time after that. Which is probably the source of the confusion.
We're currently integrating CodeMirror 6 into Overleaf [1], and you can try it out by joining our beta program [2] (which will give the option to select the beta source editor, which is the one built using CM6). If you do give it a try and spot any bugs/issues, please let us know, feedback is always much appreciated.
Thanks Marijn for all your work!
thanks for sharing
Now I would absolutely love it it Firefox would fix copy-and-paste with the primary selection so that I can actually use it in my workflow: https://bugzilla.mozilla.org/show_bug.cgi?id=1593761
This sixth version fully support touch input, that is unlike Monaco editor on vs code were you can have multiple online versions (self hosted, one hosted by Microsoft and GitHub code spaces) but none of them work well on the iPad.
I don’t know if there’s something similar to vs code already implemented with CodeMirror but I would tend to think there’s market (of free editor) for that.
https://python.microbit.org/v/beta
We’ve found CodeMirror 6’s APIs and in particular its extensibility to be well thought out and great to work with.
Thanks Marijn!
It's an incredible piece of software, and Marijn is very active in the community. We're proud sponsors of CodeMirror.
169.3 kB Minified
55.8 kB Minified + Gzipped
codemirror@6.0.0: 310.9 kB Minified
98 kB Minified + Gzipped
source: https://bundlephobia.com/package/codemirror@6.0.0