← Back to context

Comment by teddyh

12 hours ago

> A large fraction of my (blasphemous) changes was of course overriding keyboard shortcuts to match the expectations that average users have of what keyboard shortcuts should do, in at least the last 40 years of software.

You mean the same thing you can get by clicking the checkbox under OptionsCut/Paste with C-x/C-c/C-v (CUA Mode)? (And then, OptionsSave Options to… save your options.)

Some people really like to exaggerate the difficulty of Emacs, and claim that they spent ages modifying their .emacs files to do what is really the simplest of settings.

(bind-keys*

    ;; file operations

    ("C-o" . find-file)         ; open file

    ("C-s" . save-buffer)       ; save file

    ("C-S-s" . write-file)      ; save as

    ("M-Q" . kill-this-buffer)  ; close file

    ;; folder tree

    ("C-d" . neotree-toggle)  ; toggle hide/show folder tree

    ;; buffer content operations

    ("C-a" . mark-whole-buffer) ; select all

    ("C-f" . isearch-forward)   ; find in file and highlight

    ("C-S-f" . query-replace)   ; find and replace

    ("C-z" . undo-tree-undo)    ; undo

    ("C-S-z" . undo-tree-redo)  ; redo

    ("C-c" . kill-ring-save)    ; Copy

    ("C-x" . kill-region)       ; Cut

    ("C-v" . yank)              ; Paste

    ;; font size

    ("C-+" . text-scale-increase)

    ("C--" . text-scale-decrease)

    ;; Pane/buffer switching

    ("M-1" . other-window)      ; toggle

    ("M-2" . previous-buffer)   ; previous
 
    ("M-3" . next-buffer)       ; next 

    ("<M-down>" . split-window-vertically)

    ("<M-right>" . split-window-horizontally)

    ("<s-up>" . shrink-window)

    ("<s-down>" . enlarge-window)

    ("<s-left>" . shrink-window-horizontally)

    ("<s-right>" . enlarge-window-horizontally)

    ("M-q" . delete-window)     ; close window

    ;; launch term

    ("M-0" . term)

    ;; code folding

    ("M-e" . hs-show-block)

    ("M-E" . hs-hide-block)

    ("M-h" . hs-hide-all))

edit: Added extra line breaks otherwise the comment text seems to be treated as a single block of text.

Arguably some of these are not standard anything (just something I was happy with) but equally there is also a lot of normal stuff people are used to in several software applications for many decades now.

  • I would still recommend using CUA Mode over simply rebinding C-x, C-v and C-z. CUA Mode does a few more things than that, and is smarter about it: <https://www.gnu.org/software/emacs/manual/html_node/emacs/CU...>

    Also, you can prefix code blocks by two extra spaces on each line:

      (bind-keys*
       ;; file operations
       ("C-o" . find-file)         ; open file
       ("C-s" . save-buffer)       ; save file
       ("C-S-s" . write-file)      ; save as
       ("M-Q" . kill-this-buffer)  ; close file
       ;; folder tree
       ("C-d" . neotree-toggle)  ; toggle hide/show folder tree
       ;; buffer content operations
       ("C-a" . mark-whole-buffer) ; select all
       ("C-f" . isearch-forward)   ; find in file and highlight
       ("C-S-f" . query-replace)   ; find and replace
       ("C-z" . undo-tree-undo)    ; undo
       ("C-S-z" . undo-tree-redo)  ; redo
       ("C-c" . kill-ring-save)    ; Copy
       ("C-x" . kill-region)       ; Cut
       ("C-v" . yank)              ; Paste
       ;; font size
       ("C-+" . text-scale-increase)
       ("C--" . text-scale-decrease)
       ;; Pane/buffer switching
       ("M-1" . other-window)      ; toggle
       ("M-2" . previous-buffer)   ; previous
       ("M-3" . next-buffer)       ; next 
       ("<M-down>" . split-window-vertically)
       ("<M-right>" . split-window-horizontally)
       ("<s-up>" . shrink-window)
       ("<s-down>" . enlarge-window)
       ("<s-left>" . shrink-window-horizontally)
       ("<s-right>" . enlarge-window-horizontally)
       ("M-q" . delete-window)     ; close window
       ;; launch term
       ("M-0" . term)
       ;; code folding
       ("M-e" . hs-show-block)
       ("M-E" . hs-hide-block)
       ("M-h" . hs-hide-all))