Skip to content

Instantly share code, notes, and snippets.

@gcentauri
Last active January 7, 2018 16:30
Show Gist options
  • Save gcentauri/86f46d151fc01781e4a1f3b54722b3ef to your computer and use it in GitHub Desktop.
Save gcentauri/86f46d151fc01781e4a1f3b54722b3ef to your computer and use it in GitHub Desktop.
(defun xah-fly-command-mode-init ()
"Set command mode keys.
Version 2017-01-21"
(interactive)
(xah-fly--define-keys
xah-fly-key-map
'(
("~" . nil)
(":" . nil)
("SPC" . xah-fly-leader-key-map)
("DEL" . xah-fly-leader-key-map)
("'" . xah-reformat-lines)
("," . xah-shrink-whitespaces)
("-" . xah-cycle-hyphen-underscore-space)
("." . backward-kill-word)
(";" . xah-comment-dwim)
("/" . hippie-expand)
("\\" . nil)
("=" . xah-forward-equal-sign)
("[" . xah-backward-punct )
("]" . xah-forward-punct)
("`" . other-frame)
;; ("#" . xah-backward-quote)
;; ("$" . xah-forward-punct)
("1" . pop-global-mark)
("2" . xah-pop-local-mark-ring)
("3" . delete-other-windows)
("4" . split-window-below)
("5" . delete-char)
("6" . xah-select-block)
("7" . xah-select-line)
("8" . xah-extend-selection)
("9" . xah-select-text-in-quote)
("0" . nil)
("a" . execute-extended-command)
("b" . isearch-forward)
("c" . previous-line)
("d" . xah-beginning-of-line-or-block)
("e" . xah-delete-backward-char-or-bracket-text)
("f" . undo)
("g" . backward-word)
("h" . backward-char)
("i" . xah-delete-current-text-block)
("j" . xah-copy-line-or-region)
("k" . xah-paste-or-paste-previous)
("l" . nil) ;; this is QWERTY "p" set to nil so it just types p in command mode
("m" . xah-backward-left-bracket)
("n" . forward-char)
("o" . open-line)
("p" . kill-word)
("q" . xah-cut-line-or-region)
("r" . forward-word)
("s" . xah-end-of-line-or-block)
("t" . next-line)
("u" . xah-fly-insert-mode-activate)
("v" . xah-forward-right-bracket)
("w" . xah-next-window-or-frame)
("x" . xah-toggle-letter-case)
("y" . set-mark-command)
("z" . xah-goto-matching-bracket)))
(define-key xah-fly-key-map (kbd "a") (if (fboundp 'smex) 'smex 'execute-extended-command ))
(when xah-fly-swapped-1-8-and-2-7-p
(xah-fly--define-keys
xah-fly-key-map
'(
("8" . pop-global-mark)
("7" . xah-pop-local-mark-ring)
("2" . xah-select-line)
("1" . xah-extend-selection))))
(progn
(setq xah-fly-insert-state-q nil )
(modify-all-frames-parameters (list (cons 'cursor-type 'box))))
(setq mode-line-front-space "C")
(force-mode-line-update)
;;
)
@gcentauri
Copy link
Author

Maybe there's a better way, but since there is only one keymap for xah-fly-key-map which just gets overwritten when switching between command and insert mode, you need to alter the init function that sets it up when command mode is activated. Perhaps there's a way to just write a hook and use define key to make it simpler

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment