8 ms·
Pure Python Vim clone
- morekozhambu 11y agoawesome !! Does it work with unicode Indic characters?
- jonathan_s 11y agoYes, it should normally work with all unicode characters. (If not, please file a bug.)
- marktangotango 11y agoFyi there's a similar project here: https://github.com/stefanoborini/vai https://github.com/stefanoborini/vai
- rch 11y agoThis looks great - very hackable. I think I'd like to try adding support for HDF5 files via h5py.
- tomp 11y agoLike vim, just slower.™
- andybak 11y agoFrom the readme: Why did I create Pyvim? There are several reasons. The main reason is maybe because it was a small step after I created the Python prompt-toolkit library. That is a library which is actually only a simply pure Python readline replacement, but with some nice additions like syntax highlighting and multiline editing. It was never intended to be a toolkit for full-screen terminal applications, but at some point I realised that everything we need for an editor was in there and I liked to challenge its design. So, I started an editor and the first proof of concept was literally just a few hundred lines of code, but it was already a working editor. The creation of pyvim will make sure that we have a solid architecture for prompt-toolkit, but it also aims to demonstrate the flexibility of the library. When it makes sense, features of pyvim will move back to prompt-toolkit, which in turn also results in a better Python REPL. (see ptpython, an alternative REPL.) Above all, it is really fun to create an editor.
- deleted 11y ago[deleted]
- deleted 11y ago[deleted]
- evmar 11y agoMy thought process upon seeing this: "Python, huh? Seems like typos in uncommon branches of the code would cause it to randomly fail at runtime, losing your work!" "Now evmar, don't be such a internet nay-sayer, plenty of people write reliable Python code. You just need tests and... yep, there's a tests directory right there in the repository." "Let's take a look. ...there's only one test!?" It looks pretty neat other than that, though.
- david-given 11y agoI am, right now, or at least two minutes ago before I started reading HN, refactoring big chunks of _my_ text editor, WordGrinder. It's a almost-pure-Lua word processor. In the process I have been writing unit tests. Previously the program didn't have any, which was really dumb. It was dumb because, in the three days I've spent doing this, I have found (and fixed) so, _so_ many bugs. And now I have a decent set of tests, I can change something, rerun them, and have a pretty good idea of whether it worked or not. I don't even have to run the program! Unit tests. They Will Save You Time™.
- teacup50 11y agoTypes. They Will Save You Tests™ :-)
- keslag 11y agoTypes will create a false sense of security...
- vhost- 11y agoCan you elaborate?
- _yosefk 11y agoprint(arr[i]) Compiles, runs, fails if i is out of bounds. Which means that you need to test the code that you write, and that even if you have 100% line coverage (or branch coverage or MC/DC coverage or...), it doesn't mean i won't get the wrong value. People who claim that "once my C++/Haskell/Agda/whatever program compiles, I know it probably has no bugs" thus tempt others to mention "a false sense of security." (Agda might be going further than anyone else with proving that i cannot be out of bounds, AFAIK... though a generally undecidable problem will remain generally undecidable.)
- mkonecny 11y agoWas this more of a blackbox re-implementation, or is more of a 1:1 code port?
- jonathan_s 11y agoIt's a blackbox re-implementation. In Python, things are done different from C and there are other libraries are available (Pygments for instance). I also don't want to claim that it is as powerful as Vim is. But it should be stable, easy to install, and especially usable for Python development.
- eivarv 11y agoVery cool!
- kgadek 11y agoQ: Why Python? A: The only alternative would be Haskell, but I still have to learn that. Wow, that would be interesting.
- fadsasda432 11y agoHi, I once tried that, but I ran into problems with lazyness. In particular my data structure was rather simple (famous gap data structure), but editing "large" files (>1000LOC) became rather unpleasant (too big input-feedback latency). However I managed to build a _very_ basic proof-of-concept editor (no dependencies) in just a few hundreds lines of code which I could explain, but until now I was too shy to share it as it did not involve magic abstract Haskell-foo ... ;)
- implicit 11y agoThat's a shame! "Gets the job done in just a few hundred lines of easily-explained code" is a terrific standard to meet. "Magic abstract Haskell-fu" cannot improve such a program very much.
- codygman 11y ago> I was too shy to share it as it did not involve magic abstract Haskell-foo Please don't be, simple understandable Haskell code is very nice :) Plus if there is a better way of doing it you get to find that out too.
- wz1000 11y agoYi[0] is an editor written in Haskell. [0]: https://github.com/yi-editor/yi https://github.com/yi-editor/yi
- Yadi 11y agoThis is awesome, I just tested it out :)! It would be cool to have the possibility creating the extensions in future.
- chestervonwinch 11y agoTried it on OS X. Everything blinks - as in blink-tag blinks. Not sure what's going on with that...
- jonathan_s 11y agoCan you tell me what terminal application you are using? Does it happen as well in a new terminal?
- chestervonwinch 11y agodefault terminal app on osx 10.6. happens in a new terminal.
- avinassh 11y agoIs there any reason you are still using 10.6?
- chestervonwinch 11y agoold laptop. no $$.
- krick 11y agoSo is it vi clone on vim clone, exactly? I just noticed some usual things are not working (ZQ, for example), but I don't remember, maybe it's supposed to be that way in vi.
- deleted 11y ago[deleted]
- rhapsodyv 11y agoIs there any vim clone that actually have full support to vimfiles?
- amelius 11y agoWhy not decouple the following things: - Core editor (internal representation, etc.) - Key bindings (so you could easily create an emacs instead of a vi) - Rendering - Scripting language (for customized behavior) Finally, make sure you thoroughly document these building blocks, so others can create really cool stuff with it. Also, think of possible use-cases when defining the modules. A smart architecture could allow for a collaborative editor, for example.
- jonathan_s 11y agoHi, thanks for the suggestions! Actually, the internal representation, is completely separate from the layout. It's not in another repository, but it's decoupled. The key bindings are also separate. Getting emacs bindings is not much more than changing this line [0]. Only adding the bindings for the window management and emacs command line is still to be done. (I know that emacs is actually much more than only its key bindings, but you know what I mean.) The rendering is also independent. There are two backends: vt100 terminals and the windows console. (Honesly, my main focus is vt100, but any render back-end is possible. I think even graphical) The same for the event loops by the way, it can run on a couple of event loops. For instance asyncio. Documentation will follow. prompt-toolkit has already quite a lot of examples, and there's a lot of documentation in the code itself. But I agree that we should keep improving. Cheers! [0] https://github.com/jonathanslenders/pyvim/blob/master/pyvim/key_bindings.py#L26 https://github.com/jonathanslenders/pyvim/blob/master/pyvim/...
- AnkhMorporkian 11y agoI want to compliment you on your code. It's so rare to see clean python code. I am almost never able to be able to jump into a file in a module and understand exactly what's happening, but you fucking nailed it. Well done!
- notfoss 11y agoI believe he follows pep8 ;)
- 11y ago
- marco2357 11y agoThere's a Java version of Vim here: https://www.mtsystems.ch/#section2 https://www.mtsystems.ch/#section2 It's an automatic translation of the C version. Like tomp said 4 hours ago: Like vim, just slower.™
- haches 11y agoCould you make it available as a Github repo? Would allow to browse it without requiring a download.
- andor 11y agoThis is really nice. Does anybody know whether there's a comparable (real time, asynchronous, highlighting symbols not lines) syntax checker for neovim?
- esbio 11y agoHere is vai https://github.com/stefanoborini/vai https://github.com/stefanoborini/vai , a similar project I started a year and a half ago.
- yoanizer 11y agoHello, I have a question, what made you want to start this project? What do you not like about main branch vim?