adsr / mle

flexible terminal-based text editor (C)
Apache License 2.0
827 stars 53 forks source link

Are there any docs? Default keymap info? #17

Closed stacksmith closed 5 years ago

stacksmith commented 5 years ago

Looks cool but really don't feel like digging in the dirt. Am I missing something or is this project entirely undocumented? I am interested in particular in the default bindings. Thanks

adsr commented 5 years ago

Hey, thanks for your interest. The keymap is viewable by pressing F2 (by default) while the editor is running. Currently there are no docs beyond that, the README, and the manpage.

stacksmith commented 5 years ago

Great. I missed the F2 somehow. Thanks!

stacksmith commented 5 years ago

As long as I have your attention - are you planning (or is it at all possible) to have vim-like modes?

adsr commented 5 years ago

Yes, I don't use modes personally but it's possible, e.g.:

mle \
-K kmap_normal,,0 \ 
-k cmd_move_left,h, \
-k cmd_move_right,l, \
-k cmd_move_up,j, \
-k cmd_move_down,k, \
-k cmd_quit,q, \
-k cmd_push_kmap,i,kmap_insert \
-K kmap_insert,cmd_insert_data,0 \
-k cmd_pop_kmap,C-c, \
-n kmap_normal \
test.txt

This defines two kmaps: kmap_normal (h=left, l=right, j=up, k=down, q=quit, i=enter insert mode) and kmap_insert (C-c=go back to normal mode, else=insert text). You can build on this to start to approximate the feel of vim. There's editor-side support for parameterizing commands with a letter or number, e.g., for repetition, but only a few commands support it currently, like cmd_move_relative. One of these days I'd like to replace the keymap code with something more elegant.

FWIW, the default kmap, mle_normal, reflects my personal preference. It is an enhanced insert mode. If I need to move around a lot, I switch to less (Alt-L). If I need to make a complex editing maneuver, I will either pipe text into a shell command (Alt-E), pipe into a perl 1-liner (Alt-W), or (rarely) record and replay a macro (Alt-R, Alt-Z).

stacksmith commented 5 years ago

Thanks very helpful. I am not a real Vim user, but appreciate modality from a distance. I've been looking for a minimal editing solution for a while, and your project looks really good. Cranking up Emacs makes me a little sick every time (and Vim sick and confused, generally). You would do us all a favor by writing up a simple tutorial, showing how you use it to do typical things. I am not much of a video watcher (my add kicks in), but I will try. Thanks again for quick replies.