What are good custom keybindings in emacs?

后端 未结 5 546
醉梦人生
醉梦人生 2021-02-05 15:35

Emacs seems to have all the possible keyboard combinations already randomly distributed among it\'s commands. :p

If I am to define new keyboard shortcuts, where should I

5条回答
  •  日久生厌
    2021-02-05 16:31

    This is mine.

    Notice I remapped the movement keys. This was because I use the MS NS4K, which makes those particular key movements very easy.

    ;;;;;;;; remapping of keys ;;;;;;;;;;;;;;;
    
    (global-set-key "\C-cg" 'goto-line)
    ;C-c u untabifies...yuck!
    (global-set-key "\C-cu" 'untabify)
    ;Regex replace
    (global-set-key "\C-x%" `query-replace-regexp)
    ;;Backward-kill-line is defined later on in this file.
    (global-set-key "\M-k" `backward-kill-line)
    
    (global-set-key "\C-x\C-j" 'eval-print-last-sexp)
    ;;M-up/down -> start/end of buffer. Yay!
    (global-set-key (kbd "M-") 'beginning-of-buffer)
    (global-set-key (kbd "M-") 'end-of-buffer)
    (global-set-key (kbd "M-[") 'beginning-of-buffer)
    (global-set-key (kbd "M-]") 'end-of-buffer)
    
    ;;remap movement keys to get rid of emacs pinky
    ;Jump back and forth by 5.
    (global-set-key "\C-n" '(lambda () (interactive) (forward-line 5)))
    (global-set-key "\C-p" '(lambda () (interactive) (forward-line -5)))
    (global-set-key "\M-a" 'move-beginning-of-line)
    (global-set-key "\M-e" 'move-end-of-line)
    (global-set-key "\M-n" 'next-line)
    (global-set-key "\M-p" 'previous-line)
    
    ;bookmark
    (global-set-key (kbd "") 'bm-toggle)
    (global-set-key (kbd "")   'bm-next)
    (global-set-key (kbd "") 'bm-previous)
    (setq bm-cycle-all-buffers t)
    
    (global-set-key (kbd "") 'revert-buffer)
    (global-set-key (kbd "") 'delete-trailing-whitespace)
    (global-set-key (kbd "") 'comment-or-uncomment-region)
    
    (global-set-key (kbd "M-RET") 'newline-and-indent)
    (global-set-key "\C-m" 'newline-and-indent)
    
    ;;Jump "backwards"
    (global-set-key "\C-xp" '(lambda () (interactive) (other-window -1)))
    
    ;;copy
    (global-set-key "\M-y" 'yank)
    
    ;;insert line
    (global-set-key "\M-o" '(lambda () (interactive) (open-line 1)))
    
    ;zap to char backwards
    (global-set-key "\C-z" 'minimize)
    ;;suspend-emacs is the send-to-background command on linux
    
    ;simplify register usage
    (global-set-key "\M-s" 'copy-to-register)
    (global-set-key "\M-i" 'insert-register)
    
    ;;autocomplete hacks
    (global-set-key [?\M-/] 'hippie-expand)
    (global-set-key [?\C-/] 'dabbrev-expand)
    
    
    (global-set-key [?\C-.] 'find-tag)
    ;(global-set-key "\C-.\C-s" 'find-tag)
    (global-unset-key [?\M-.])
    
    ;;this lets us have long lines go off the side of the screen instead of hosing up the ascii art
    (global-set-key "\C-t" 'toggle-truncate-lines)
    
    ;comment/uncomment region
    (global-set-key "\C-c\C-c" 'comment-or-uncomment-region)
    
    ;;Buffer-move
    (global-set-key (kbd "")   'buf-move-left)
    (global-set-key (kbd "")  'buf-move-right)
    

提交回复
热议问题