Live data from Hacker News

Writing an editor in less than 1000 lines of code, just for fun

antirez.com

11–20 of 146 posts

Re: Writing an editor in less than 1000 lines of code, just for fun

#11
post #9
post #6

Earlier quoted context omitted.

Presumably h, j, k, l will always get you around in vi?

j and k behavior may vary depending on your config.

Everything can vary depending on your config, but unless they were explicitly remapped, j and k should pretty much do the same thing everywhere.

Have you seen somewhere where that isn't the case?

Re: Writing an editor in less than 1000 lines of code, just for fun

#13
This is the kind of magic that got me excited about programming in the first place.

I remember being in high school and one day, after class, a friend of mine mentioned that the best programmer we knew had once written a breakout clone with ANSI "graphics." We found him and he said he didn't have the source any more, but we asked him how he did it. He then proceeded to rewrite the whole thing, in Pascal, in about an hour, this time adding animations. Thanks antirez for bringing back that feeling (and, oh yeah, for redis too ;))

PS. the "Low level terminal handling" is gold here.

Re: Writing an editor in less than 1000 lines of code, just for fun

#14
post #6
post #4

Earlier quoted context omitted.

Nice thing about Nano is that they arrow keys always seem to do what they are supposed to, no matter the system, shell, TTY, etc. Vi seems to have issues sometimes, and needs extra config

Presumably h, j, k, l will always get you around in vi?

Yeah but that is so much less usable. Quick, which one is up?

Re: Writing an editor in less than 1000 lines of code, just for fun

#16
post #5
post #4

Earlier quoted context omitted.

Nice thing about Nano is that they arrow keys always seem to do what they are supposed to, no matter the system, shell, TTY, etc. Vi seems to have issues sometimes, and needs extra config

I don't know about vi (I think it's still rare on Linux systems), but Vim typically does what is expected from it.

If you ever happen to bork your kernel badly enough to prevent it from booting, you'll find a classic VI pretty quickly, and probably be grateful for it.

Re: Writing an editor in less than 1000 lines of code, just for fun

#17
post #6

Earlier quoted context omitted.

Presumably h, j, k, l will always get you around in vi?

Yeah but that is so much less usable. Quick, which one is up?

k of course. Having said that, experienced vi/vim users rarely use jk to get around. Instead we use { } / f etc.

Re: Writing an editor in less than 1000 lines of code, just for fun

#18
post #6

Earlier quoted context omitted.

Presumably h, j, k, l will always get you around in vi?

Yeah but that is so much less usable. Quick, which one is up?

Just look at your keyboard :-)

(https://en.m.wikipedia.org/wiki/ADM-3A#Legacy)

I always try to remember them by noting that the leftmost key moves left, the rightmost key moves right (not too hard), and that 'K climbs' (using alliteration to remember that). That leaves 'J' for cursor down.

In practice, though, I use the cursor keys. Luckily, they work on the editors/systems I work on nowadays. Side effect is that I am very bad at remembering those mnemonics.

Re: Writing an editor in less than 1000 lines of code, just for fun

#19
post #6

Earlier quoted context omitted.

Presumably h, j, k, l will always get you around in vi?

Yeah but that is so much less usable. Quick, which one is up?

I know k is up, because I constantly k in bash, bit the point of using hjkl is exactly not to know which one is what. You set your finger on the keyboard in home position, now your muscle memory does the rest.

Re: Writing an editor in less than 1000 lines of code, just for fun

#20
Back in the 90's I took a class in Visual Basic, where one of the assignments was to write a rules-compliant tic-tac-toe game. The teacher apologized for the amount of repetitive code we'd have to write to implement it in Windows forms (or whatever it was called back then). I got it down to one printed page.
Post reply on HN