110

GitHub - DogLooksGood/meow: Modal Editing On Wheel

 3 years ago
source link: https://github.com/DogLooksGood/meow
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Less is more

Highlights

  • Semantic but still effective layout on Dvorak, Colemak and Qwerty.
  • A complete modal editing plays well with special modes, like dired, etc. Never pay for compatibility.
  • Combine navigation and selection, rarely use a command to activate selection.
  • Use kbd macros when calling underlying commands, drop-in replacement will work out-of-box.
  • A keypad state allows you execute commands from C-x and C-c keymaps without modifiers.

Installation

Melpa

(use-package meow
  :init
  (meow-global-mode 1)
  :custom
  ;; layout options: qwerty, dvorak, dvp, colemak
  (meow-layout 'qwerty))

use-package with quelpa

:quelpa (rime :fetcher github
              :repo "DogLooksGood/meow")

use-package with straight

:straight (rime :type git
                :host github
                :repo "DogLooksGood/meow")

Modal States

INSERT

Just vanilla Emacs, the only difference is that you can switch to NORMAL state with ESC.

NORMAL

Check layout.html in this repo, you can find layout for Qwerty, Dvorak, Colemak and Programmer Dvorak.

Here's an example for Dvorak.

Cheatsheet

Prefix Arguments

Use -, ' and 0 to 9.

Toggle States

With i, a, o, x.

Navigation/Selection

The Concept: Meow steals the idea from kakoune, except h/t/p/n, every navigation command will mark something. And you can enter INSERT state at beginning of region with i or at end of region with a or use r to reverse the direction of selection.

NOTE: The keys on Qwerty has some tweaks, check layout.html.

Benefits:

  • By one navigation, you get two position, both of them are pretty meaningful.
  • Make it much easier to quick mark something before copy or kill.

Simple

Use h (Head, left), t (Tail, right), p (Prev), n (Next) for single char navigation.

These commands will cancel all selection except those with char type, and use with Shift will activate selection with char type.

Word

Use m (Mark or Back Word) to mark current word with selection type word-mark.

When selection type is word-mark, m will move to the previous word.

Use w (Forward Word) to mark the next word with selection type word.

When selection type is word-mark, w will expand selection by word and change selection type to word-expand, this type of selection will be cancelled by m.

Line

Use l (Line) to mark the whole line with selection type line.

When selection type is line, l will expand selection by line.

Block

Use b (Block) to expand selection to current block. By default the block is identified with a pair of parentheses. This is useful in Lisp dialects. However languages like python, haskell don't wrap everything with parentheses, so there's a fallback behavior which identify block with indentation.

Press b multiple times will expand the region. Expanding will stop at top-level form, so hold b to mark the whole top-level block.

b will also work in string or comment.

Exp

Use e (Exp) to mark current sexp with selection type exp.

When selection type is exp, e will mark the next one. During the movement, cursor will not escape from the current block, if current sexp is the last sexp in this block, e will reverse the direction of selection.

Forwarding

Use f (Forwarding) to make a selection from current point(as mark) to the end of current line or end of current block.

Use negative argument for backwarding.

Deletion

Use k to kill region.

Use d to delete char.

Use j to join current line to the previous line.

Use z to shrink multiple whitespaces into one, then toggle between one spaces and zero spaces.

Use x to kill region then switch to INSERT state.

Other commands

u (Undo) undo the changes, but will only pop to the previous selection when region is active.

MOTION

Default state for special-mode buffers. There are only two additional bindings in MOTION state.

SPC is used as LEADER key, the original command on SPC is bound to SPC SPC.

ESC is used to switch to previous buffer.

KEYPAD

This is inspired by god-mode. You can activate KEYPAD state with SPC x or SPC c in NORMAL and MOTION state.

In this state, every single key is considered with Control, x means C-x; If you want a single x, use SPC x; If you want a M-x, use m x.

To call a command on C-c M-j, use SPC c m j.

To call a command on C-c C-x RET, use SPC c x SPC RET. If there's no command on C-c C-x C-RET, it is okay to omit the second SPC, just use SPC c x RET.

Customize Leader Keymap

Use meow-leader-define-key and meow-leader-define-mode-key to customize leader keymap.

;; Put these in the :config section in use-package

(meow-leader-define-key
 '("k" . kill-buffer)
 '("l" . goto-line)
 '("h" . other-window)
 '("o" . delete-other-windows)
 '("-" . split-window-below)
 '("/" . swiper)
 '("\\" . split-window-right)
 '("m" . magit-status)
 '("f" . find-file)
 '("F" . find-file-literally))

(meow-leader-define-mode-key
 'emacs-lisp-mode
 '("RET" . eval-buffer)
 '("SPC" . eval-defun))

LICENSE

License under GPL v3.


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK