;;; init-terminal-kbd.el --- keybindings -*- lexical-binding: t -*- ;;; Commentary: ;;; Code: ;; 修改mac键位 (when *is-mac* (setq mac-command-modifier 'meta) (setq mac-option-modifier 'none)) (defun open-init-file() "Open user's init.el file in ~/.emacs.d ." (interactive) (find-file "~/.emacs.d/init.el")) (defun duplicate-and-move-to-next-line() "Duplicate current line and move to next line." (interactive) (progn (duplicate-line) (next-line))) (defun popper-toggle-type-delete-other-window() "Toggle type of popper window and delete other window." (interactive) (popper-toggle-type) (delete-other-windows)) ;; scratch buffer (if *is-mac* (general-def "C-c " 'scratch-buffer) (general-def "C-c " 'scratch-buffer)) ;; markdown (general-def markdown-mode-map "M-p" nil "M-n" nil) ;; org-mode (general-def org-mode-map "C-" 'org-cycle-current-subtree "C-c o l" 'org-toggle-link-display) ;; global map with C-c prefix (general-def :prefix "C-c" "c" 'hydra-multiple-cursors/body "e" 'er/expand-region "k" 'comment-line) ;; global map (general-def ;; buffer, file, and window "" 'open-init-file "M-[" 'previous-buffer "M-]" 'next-buffer "C-x C-b" 'ibuffer-other-window "C-x K" 'crux-kill-other-buffers ;; edit "M-c" 'capitalize-dwim "M-u" 'upcase-dwim "M-l" 'downcase-dwim "C-," 'duplicate-and-move-to-next-line "C-k" 'crux-smart-kill-line "C-" 'crux-kill-line-backwards "C-o" 'open-line "C-a" 'crux-move-beginning-of-line "M-y" 'consult-yank-from-kill-ring "C-c " 'hungry-delete-backward "C-c C-" 'hungry-delete-forward "M-P" 'drag-stuff-up "M-N" 'drag-stuff-down ;; undo "C-/" 'undo-fu-only-undo "C-?" 'undo-fu-only-redo ;; navigate "M-p" 'backward-paragraph "M-n" 'forward-paragraph "" 'xref-find-definitions-at-mouse "C-M-;" 'avy-goto-char "C-M-'" 'avy-goto-word-1 "M-g g" 'avy-goto-line ;; window "M-" 'shrink-window-horizontally "M-" 'enlarge-window-horizontally "M-" 'shrink-window "M-" 'enlarge-window "M-`" 'popper-toggle "C-M-=" 'popper-toggle-type-delete-other-window "M-o" 'other-window "" 'esw/swap-two-windows ;; other "" 'global-tab-line-mode) ;; expand region (setq expand-region-reset-fast-key "r") (setq expand-region-contract-fast-key "c") ;; save-some-buffer时diff更改 (add-to-list 'save-some-buffers-action-alist (list "d" (lambda (buffer) (diff-buffer-with-file (buffer-file-name buffer))) "show diff between the buffer and its file")) ;; hydra (use-package hydra :defines (consult-imenu-config) :init (with-eval-after-load 'consult-imenu (setq consult-imenu-config '((emacs-lisp-mode :toplevel "Functions" :types ((?f "Functions" font-lock-function-name-face) (?h "Hydras" font-lock-constant-face) (?m "Macros" font-lock-function-name-face) (?p "Packages" font-lock-constant-face) (?t "Types" font-lock-type-face) (?v "Variables" font-lock-variable-name-face))))))) ;; multiple-cursors (defhydra hydra-multiple-cursors () " ^Mark^ ^Unmark^ ^Other^ ------------------------------------------------------------------ _p_ : prev line _P_ : previous _c_ : edit lines _n_ : next line _N_ : next _._ : pop _b_ : prev word _q_ : quit _f_ : next word _B_ : prev symbol _F_ : next symbol _s_ : in region _a_ : all dwim " ("p" mc/mark-previous-like-this) ("n" mc/mark-next-like-this) ("b" mc/mark-previous-like-this-word) ("f" mc/mark-next-like-this-word) ("B" mc/mark-previous-like-this-symbol) ("F" mc/mark-next-like-this-symbol) ("P" mc/unmark-previous-like-this) ("N" mc/unmark-next-like-this) ("a" mc/mark-all-dwim) ("s" mc/mark-all-in-region) ("c" mc/edit-lines) ("." mc/mark-pop) ("q" nil)) (provide 'init-terminal-kbd) ;;; init-terminal-kbd.el ends here