Last active
September 5, 2018 15:01
-
-
Save kngwyu/93d444b6f9f17ba9cf351c2ac310baee to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
from xkeysnail.transform import * | |
# Emacs-like keybindings in non-Emacs applications | |
define_keymap(re.compile("Firefox"), { | |
# Ctrl+Alt+j/k to switch next/previous tab | |
K("Caps-M-j"): K("C-TAB"), | |
K("Caps-M-k"): K("C-Shift-TAB"), | |
# Type Caps-j to focus to the content | |
K("Caps-j"): K("C-f6"), | |
# Cursor | |
K("Caps-b"): with_mark(K("left")), | |
K("Caps-f"): with_mark(K("right")), | |
K("Caps-p"): with_mark(K("up")), | |
K("Caps-n"): with_mark(K("down")), | |
K("Caps-h"): with_mark(K("backspace")), | |
# Forward/Backward word | |
K("M-b"): with_mark(K("C-left")), | |
K("M-f"): with_mark(K("C-right")), | |
# Beginning/End of line | |
K("Caps-a"): with_mark(K("home")), | |
K("Caps-e"): with_mark(K("end")), | |
# Page up/down | |
K("M-v"): with_mark(K("page_up")), | |
K("Caps-v"): with_mark(K("page_down")), | |
# Beginning/End of file | |
K("M-Shift-comma"): with_mark(K("C-home")), | |
K("M-Shift-dot"): with_mark(K("C-end")), | |
# Newline | |
K("Caps-m"): K("enter"), | |
K("Caps-j"): K("enter"), | |
K("Caps-o"): [K("enter"), K("left")], | |
# Copy | |
K("Caps-w"): [K("C-x"), set_mark(False)], | |
K("M-w"): [K("C-c"), set_mark(False)], | |
K("Caps-y"): [K("C-v"), set_mark(False)], | |
# Delete | |
K("Caps-d"): [K("delete"), set_mark(False)], | |
K("M-d"): [K("C-delete"), set_mark(False)], | |
# Kill line | |
K("Caps-k"): [K("Shift-end"), K("C-x"), set_mark(False)], | |
# Undo | |
K("Caps-slash"): [K("C-z"), set_mark(False)], | |
K("Caps-Shift-ro"): K("C-z"), | |
# Mark | |
K("Caps-space"): set_mark(True), | |
K("Caps-LEFT_BRACE"): set_mark(True), | |
# Search | |
K("Caps-s"): K("F3"), | |
K("Caps-r"): K("Shift-F3"), | |
K("M-Shift-key_5"): K("C-h"), | |
# Cancel | |
K("Caps-g"): [K("esc"), set_mark(False)], | |
# Escape | |
K("Caps-q"): escape_next_key, | |
# Caps-x YYY | |
K("Caps-x"): { | |
# Caps-x h (select all) | |
K("h"): [K("C-home"), K("C-a"), set_mark(True)], | |
# C-x C-f (open) | |
K("Caps-f"): K("C-o"), | |
# Caps-x C-s (save) | |
K("Caps-s"): K("C-s"), | |
# Caps-x k (kill tab) | |
K("k"): K("C-f4"), | |
# Caps-x C-c (exit) | |
K("Caps-c"): K("C-q"), | |
# cancel | |
K("Caps-g"): pass_through_key, | |
# C-x u (undo) | |
K("u"): [K("C-z"), set_mark(False)], | |
} | |
}, "Emacs-like keys") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment