在emacs中你最喜欢的全局键绑定是什么?

Nav*_*een 25 emacs

我的是:

(global-set-key [f6] 'compile-buffer)
(global-set-key [f7] 'kmacro-start-macro-or-insert-counter)
(global-set-key [f8] 'kmacro-end-and-call-macro)
(global-set-key [f9] 'call-last-kbd-macro)
(global-set-key [f10] 'name-and-insert-last-kbd-macro)
(global-set-key [f12] 'menu-bar-open)  ; originally bound to F10
(global-set-key "\C-cR" 'rename-current-file-or-buffer)
(global-set-key "\C-cD" 'Delete-current-file-or-buffer)
Run Code Online (Sandbox Code Playgroud)

name-and-insert-last-keyboard-macro是从另一个堆栈溢出问题.

Boz*_*sov 25

我碰巧有很多这些:

;; You know, like Readline.
(global-set-key (kbd "C-M-h") 'backward-kill-word)

;; Align your code in a pretty way.
(global-set-key (kbd "C-x \\") 'align-regexp)

;; Perform general cleanup.
(global-set-key (kbd "C-c n") 'cleanup-buffer)

;; Font size
(define-key global-map (kbd "C-+") 'text-scale-increase)
(define-key global-map (kbd "C--") 'text-scale-decrease)

;; Use regex searches by default.
(global-set-key (kbd "C-s") 'isearch-forward-regexp)
(global-set-key (kbd "\C-r") 'isearch-backward-regexp)
(global-set-key (kbd "C-M-s") 'isearch-forward)
(global-set-key (kbd "C-M-r") 'isearch-backward)

;; Jump to a definition in the current file. (This is awesome.)
(global-set-key (kbd "C-x C-i") 'ido-imenu)

;; File finding
(global-set-key (kbd "C-x M-f") 'ido-find-file-other-window)
(global-set-key (kbd "C-x C-M-f") 'find-file-in-project)
(global-set-key (kbd "C-x f") 'recentf-ido-find-file)
(global-set-key (kbd "C-c r") 'bury-buffer)
(global-set-key (kbd "M-`") 'file-cache-minibuffer-complete)

;; Window switching. (C-x o goes to the next window)
(global-set-key (kbd "C-x O") (lambda ()
                                (interactive)
                                (other-window -1))) ;; back one
(global-set-key (kbd "C-x C-o") (lambda ()
                                  (interactive)
                                  (other-window 2))) ;; forward two

;; Indentation help
(global-set-key (kbd "C-x ^") 'join-line)
(global-set-key (kbd "C-M-\\") 'indent-region-or-buffer)

;; Start proced in a similar manner to dired
(global-set-key (kbd "C-x p") 'proced)

;; Start eshell or switch to it if it's active.
(global-set-key (kbd "C-x m") 'eshell)

;; Start a new eshell even if one is active.
(global-set-key (kbd "C-x M") (lambda () (interactive) (eshell t)))

;; Start a regular shell if you prefer that.
(global-set-key (kbd "C-x M-m") 'shell)

;; If you want to be able to M-x without meta
(global-set-key (kbd "C-x C-m") 'execute-extended-command)

;; Fetch the contents at a URL, display it raw.
(global-set-key (kbd "C-x C-h") 'view-url)

;; Help should search more than just commands
(global-set-key (kbd "C-h a") 'apropos)

;; Should be able to eval-and-replace anywhere.
(global-set-key (kbd "C-c e") 'eval-and-replace)

;; Magit rules!
(global-set-key (kbd "C-x g") 'magit-status)

;; This is a little hacky since VC doesn't support git add internally
(eval-after-load 'vc
  (define-key vc-prefix-map "i" '(lambda () (interactive)
                                   (if (not (eq 'Git (vc-backend buffer-file-name)))
                                       (vc-register)
                                     (shell-command (format "git add %s" buffer-file-name))
                                     (message "Staged changes.")))))

;; Activate occur easily inside isearch
(define-key isearch-mode-map (kbd "C-o")
  (lambda () (interactive)
    (let ((case-fold-search isearch-case-fold-search))
      (occur (if isearch-regexp isearch-string (regexp-quote isearch-string))))))

;; Org
(define-key global-map "\C-cl" 'org-store-link)
(define-key global-map "\C-ca" 'org-agenda)

;; program shortcuts - s stands for windows key(super)
(global-set-key (kbd "s-b") 'browse-url)          ;; Browse (W3M)
(global-set-key (kbd "s-f") 'browse-url-firefox)  ;; Firefox...
(global-set-key (kbd "s-l") 'linum-mode)          ;; show line numbers in buffer
(global-set-key (kbd "s-r") 're-builder)          ;; build regular expressions

;; Super + uppercase letter signifies a buffer/file
(global-set-key (kbd "s-S")                       ;; scratch
                (lambda()(interactive)(switch-to-buffer "*scratch*")))
(global-set-key (kbd "s-E")                       ;; .emacs
                (lambda()(interactive)(find-file "~/emacs/dot-emacs.el")))

;; cycle through buffers
(global-set-key (kbd "<C-tab>") 'bury-buffer)

;; use hippie-expand instead of dabbrev
(global-set-key (kbd "M-/") 'hippie-expand)

;; spell check Bulgarian text
(global-set-key (kbd "C-c B")
                (lambda()(interactive)
                  (ispell-change-dictionary "bulgarian")
                  (flyspell-buffer)))

;; replace buffer-menu with ibuffer
(global-set-key (kbd "C-x C-b") 'ibuffer)

;; interactive text replacement
(global-set-key (kbd "C-c C-r") 'iedit-mode)

;; swap windows
(global-set-key (kbd "C-c s") 'swap-windows)

;; duplicate the current line or region
(global-set-key (kbd "C-c d") 'duplicate-current-line-or-region)

;; rename buffer & visited file
(global-set-key (kbd "C-c r") 'rename-file-and-buffer)

;; open an ansi-term buffer
(global-set-key (kbd "C-x t") 'visit-term-buffer)

;; macros
(global-set-key [f10]  'start-kbd-macro)
(global-set-key [f11]  'end-kbd-macro)
(global-set-key [f12]  'call-last-kbd-macro)

(provide 'bindings-config)
Run Code Online (Sandbox Code Playgroud)

我实际上有一个专门用于全局键绑定的整个Emacs Lisp文件:-)

  • 你应该看到我的其他配置;-) (2认同)

Sea*_*ean 7

我的一些更不寻常的绑定:

(global-set-key [pause] 'emms-pause)
Run Code Online (Sandbox Code Playgroud)

pause在很长一段时间内首先很好地使用钥匙!

(global-set-key [(super \\)] 'find-file-at-point)
Run Code Online (Sandbox Code Playgroud)

只是全方位有用.

(global-set-key [(super s)] 'shell)
(global-set-key [(meta  p)] 'shell)
Run Code Online (Sandbox Code Playgroud)

有了第二个结合,我可以快速输入M-p M-p RET到返回到shell缓冲区和重复最后命令我输入那里.

然后是解除绑定:

(global-unset-key "\C-x\C-n")
Run Code Online (Sandbox Code Playgroud)

从来没有真正的使用set-goal-column,并始终保持绊倒了.

(when window-system (global-unset-key "\C-z"))
Run Code Online (Sandbox Code Playgroud)

我讨厌它,当我不小心输入C-z和图标化了我的躯体.

现在我们得到一个小元:

(defmacro global-set-key* (keys &rest body)
  `(global-set-key ,keys (lambda () (interactive) ,@body)))
Run Code Online (Sandbox Code Playgroud)

只是一个小按键,节能设备,让我写这样的东西:

(global-set-key* [(shift control n)] (next-line) (scroll-up 1))
(global-set-key* [(shift control p)] (previous-line) (scroll-down 1))
Run Code Online (Sandbox Code Playgroud)


Dan*_*tin 5

有关这方面的信息请访问http://sites.google.com/site/steveyegge2/effective-emacs中的 Steve Yegge

(global-set-key "\C-w" 'backward-kill-word)
(global-set-key "\C-x\C-k" 'kill-region)
(global-set-key "\C-c\C-k" 'kill-region)
Run Code Online (Sandbox Code Playgroud)

让Ctrl-w意味着我曾经拥有它的意思真的很棒.

(还查看该文章了解更多)