Skip to content

Latest commit

 

History

History
127 lines (82 loc) · 5.13 KB

TUTORIAL.org

File metadata and controls

127 lines (82 loc) · 5.13 KB

TUTORIAL

Keybindings Cheat Sheet

We have created some recommended configs for specific keyboard layouts that you can re-use for a quick setup.

QWERTY - DVORAK - PROGRAMMER DVORAK - COLEMAK

You can very easily change any of these when you setup Meow.

Tutor inside Emacs

There is a tutor inside Emacs after installing Meow. Open it with M-x meow-tutor.

States

Meow’s modal editing has 5 states: NORMAL, INSERT, MOTION, KEYPAD and BEACON. In this tutorial, we will walk through these states and basic operations.

INSERT

You can switch to INSERT state with meow-insert/append/change/open-below/open-above.

There’s nothing special in INSERT state, except ESC is bound to meow-insert-exit. Use it to go back to NORMAL state.

NOTE:

If you enter INSERT state by meow-change, the inserted content will be selected when you exit.

NORMAL

NORMAL state is the default state for text editing.

For commands in NORMAL state is defined via meow-normal-define-key.

Check here for command documents

MOTION

MOTION state is the default state for special modes, like dired, proced, etc.

By default, MOTION state has no keybindings, except SPC is used as the leader key. The original command on SPC can be access via SPC SPC.

Users may want a consistent keybindings for movement globally, for example: k/j to move up/down. Usually, you can bind k/j in MOTION state, however the original command on k/j is not accessible. To solve the problem, Meow introduce a simple solution.

For any keybinding you defined with meow-motion-overwrite-define-key, the overwrited command will be bound to the key with hyper modifier.

Here’s an example: you want use j as next-line globally.

(meow-motion-overwrite-define-key '("j" . next-line))
(meow-leader-define-key '("j" . "H-j"))

Now j will act as next-line, the original command on j (e.g. dired-goto-file in dired) will be bound to H-j. Since we use j in the leader for H-j, now we can call it via SPC j.

It is also possible to route the original command(e.g. j) to original motion key(e.g. n).

(meow-motion-overwrite-define-key '("j" . next-line))
(meow-motion-overwrite-define-key '("n" . "H-j"))

Now you have swapped j and n.

The settings we made has nothing to do with the name of a command. Thus, it works in all special modes.

KEYPAD

KEYPAD is the state used for executing commands without modifier keys.

Entering KEYPAD state by pressing one of following keys in NORMAL or MOTION state.

  • SPC x, start with C-x
  • SPC c, start with C-c
  • SPC h, start with C-h
  • SPC m, start with M-
  • SPC g, start with C-M-

Once KEYPAD state is enabled, your single keys will be translated as the key modified by C-. For example, SPC c t t will be treated as C-c C-t C-t.

And there’re three prefix keys:

  • g for C-M-
  • m for M-
  • SPC, literal prefix, means do not modify the next key

And it is possible to omit SPC if there’s no ambiguity.

For example, to execute C-M-x C-a M-b c d, press g x a m b SPC c SPC d, or maybe g x a m b c d.

After command execution, no matter succeed or failed, KEYPAD state will be disabled.

BEACON

BEACON - Batch KMacro

BEACON is the state used for applying kmacro to multiple places quickly. It’s kinda like multiple-cursors, but it works differently.

BEACON state will be enabled automatically when cursor moves into the secondary selection. BEACON state will be disabled automatically when cursor moves out or secondary selection is disabled.

Once BEACON state is enabled, you can create fake cursors/regions with movement commands.

  • meow-left/right will create cursors in current column.
  • meow-next/back-word/symbol will create cursors at words’ beginning or end.
  • meow-mark-word/symbol will create regions for every same words.
  • meow-visit/search will create regions for every same regexp.
  • meow-find/till will create cursors for every same characters.
  • meow-line will create regions for every N lines. (N is the number of selected lines).
  • meow-join will cerate cursors for each indentation beginning.

Once you have fake cursors/regions, you have two options:

  • quickly & simple Switch to INSERT state and start recording kmacro with meow-insert/append/change, finish recording and apply this kmacro to all cursors/regions when exit INSERT state.
  • generally Start recording with F3 (kmacro-start-macro-or-insert-counter or kmacro-start-macro), finish recording and apply this kmacro to all cursors/regions with F4 (kmacro-end-or-call-macro or kmacro-end-macro).

NOTE:

  • Your recorded kmacro can be used later.
  • Your can use your recorded kmacro with F4 directly.
  • You can’t use KEYPAD in BEACON state.
  • Once you start recording kmacro with F3, you will be in NORMAL state.