Live data from Hacker News

Ask HN: What would it take to rewrite Vim?

news.ycombinator.com

1–10 of 16 posts

Ask HN: What would it take to rewrite Vim?

#1
(Yes, I'm crazy, I know.)

So, I'm somewhat okay at programming, with an early-intermediate level of proficiency in Python and C++ by now.

I'd like to know what it would take to rewrite Vim from scratch, with the long term goals of adding in all the sweet Emacs stuff (like integrated scripting and the like) as well as things like an integrated package manager etc.

What things would I need to teach myself? Bear in mind that I do not have much real programming "experience" (as in, I've only written I am aware of NeoVim, please don't simply point me to it :) Think of this as a stupid personal project, if you will (although I do plan to put this on GitHub and am open to collaboration if it gains any momentum). It doesn't need to be compatible with Vim at all.

Re: Ask HN: What would it take to rewrite Vim?

#2
I've always wished that other editors would have a full featured vim mode. Either something like RStudio/eclipse using a real vim instead of a few key bindings or a more modern editor like atom.io with a complete vi implementation. Just a thought.

Good luck with your project.

Re: Ask HN: What would it take to rewrite Vim?

#4
software architecture is a bitch, so reading about the book open source software architecture could give you good ideas.

To be more specific decoupling the rendering, from the commands, from the inputs, from the external processes would go a long way.

And some reactive programming model would likely works.

Re: Ask HN: What would it take to rewrite Vim?

#7
post #2

I've always wished that other editors would have a full featured vim mode. Either something like RStudio/eclipse using a real vim instead of a few key bindings or a more modern editor like atom.io with a complete vi implementation. Just a thought. Good luck with your project.

IntelliJ and all its relatives (PyCharm, WebStorm, PHPStorm, etc) have a plugin called "IdeaVim" which fits pretty well with all the usual Vim muscle memory while giving you the toolset of a rich IDE.

Re: Ask HN: What would it take to rewrite Vim?

#10
> what it would take to rewrite Vim from scratch

Time, mainly. Computers these days are fast enough, and have enough storage space that writing Vim will be mostly straight forwards.

The first thing to do, as is for all software, is to make a spec and a roadmap. The doesn't have to be anything too serious, hell, you don't even have to write it out if you don't want to - this is your project after all. (But writing thing down is highly recommended.)

Your spec and roadmap, whether just a notion in your head, or a multi-page written out document with pictures and graphs, should talk about every single feature you want, then break those down into milestones and then break those down into smaller and smaller steps, until they're small enough that you can just start coding (or start googling for the right library)

> What things would I need to teach myself?

Well, you say you know Python and C++. Both are valid choices to write HunnypotVim in; it's your project, so pick one or the other (or a combination of both if you're feeling masochistic). Whatever you chose, you'll need to teach yourself various libraries and their API for your chosen language.

Next, you'll have to decide if you want to make a terminal program, or if you'd rather write a GVim style GUI editor. If you chose a terminal program, you'll need to learn ncurses; a GUI program will need a GUI toolkit, such as QT. Ncurses will have the 'getch' single-character input reader that you'll need in order to reimplement Vim.

You'll also need to learn how to parse command line arguments and file IO.

I'd probably start with a trivial command line argument parser, then move onto basic fileIO before starting in on the ncurses frontend development. Implement normal mode, then hjkl movement keys, finish up with a basic insert mode, and you've got your basic Vim clone!

Additional features left as an exercise for the reader ;)

My email's in my profile if you'd like to discuss this further.

Good luck, and happy coding!

Post reply on HN