Skip to content

DevelopmentCool2449/standard-keys-mode

Repository files navigation

standard-keys-mode

Introduction

standard-keys-mode is yet another CUA-like mode that aims to emulate the standard and common keybindings found in many modern editors.

Motivation

Using Emacs is often difficult, and configuring its shortcuts tedious, within the Emacs ecosystem there have been packages that tried to change these shortcuts to ones easier to use and more common in modern times. However, over time, many are becoming obsolete, are often not easy to configure or do not work in current versions of Emacs.

My frustration, and seeing how there are more modal-editing packages than modifier-based ones, motivated me to create standard-keys-mode.

This packages aims to help newcomers to use Emacs while keeping familiar keybinding, be easy-to-use and easy-to-configure.

For those who already use Emacs, this package can be considered as the meow or ryo of modifier-based shortcuts, providing the following features inspired by these packages:

  • Ready to use. No need to make so much configurations.
  • Easy to use. You can use the common keys you mostly know.
  • Minimal but easy to extend. No dependencies needed, allowing creating your own modifier-based environment.
  • Provide new editing commands that are not available in Emacs.
  • Compatible with Emacs Ecosystem. The keybindings will remain compatible with the vanilla Emacs and third-party packages keymaps, without the need to modify them or reinvent the wheel.

For install and use standard-keys-mode, see the GET_STARTED.org file, which additionally provides a simple and documented template configuration with several tips to help you get started with Emacs and standard-keys easily.

Configuration

Keybindings

standard-keys-mode comes with additional ready-to-use keymaps themes based on other editors, keyboards, and Emacs packages.

For more information about the keymaps you can see the following files:

standard-keys uses the following shortcuts by default (defined in standard-keys-default-keymap):

keycommand
Control ofind-file (Open file)
Control Shift orevert-buffer (Refresh/Update current buffer file state)
Control wkill-current-buffer (Quit/Kill current buffer)
Control qsave-buffers-kill-terminal (Quit Emacs)
Control eC-x prefix
Control dC-c prefix
Control xkill-region (Cut)
Control ckill-ring-save (Copy)
Control vyank (Paste)
Control zundo
Control yundo-redo (Redo)
Control Shift zundo-redo (Redo)
Control fisearch-forward (Search forward)
Control Shift fisearch-backward (Search backward)
Control rquery-replace (Replace)
Control Shift rquery-replace-regexp (Replace with regexp)
Control ssave-buffer (Save buffer/file)
Control Shift swrite-file (Save buffer/file as)
Control pprint-buffer (Print buffer/file)
Control amark-whole-buffer (Select All)
Control +text-scale-increase (Zoom in)
Control -text-scale-decrease (Zoom out)
Control =text-scale-adjust (Set Zoom)
Control nstandard-keys-create-new-buffer (Create a new empty buffer)
Control ;comment-line (Comment out current line)
Alt/Meta 1delete-other-windows
Alt/Meta 2split-window-below
Alt/Meta 3split-window-right
Control RETURNrectangle-mark-mode (Select in rectangle mode)
Control Shift RETURNstandard-keys-newline-and-indent-before-point (Insert a newline before cursor)
Control bswitch-to-buffer
HOMEstandard-keys-move-beginning-of-line-or-indentation
ESCstandard-keys-keyboard-quit (Cancel current action, similar to C-g)

User options

  • standard-keys-update-commands-descriptions

    If non-nil, commands docstring descriptions should use the remaped C-x and C-c.

    This only have effect if standard-keys-update-commands-descriptions is non-nil.

    default: t

  • standard-keys-override-new-C-x-and-C-c-commands

    If non-nil, commands bounds in C-x and C-c must take precedence over other keymaps.

    WARNING: This only should be used only for override the C-x and C-c only in buffers or modes which take precedence over standard-keys-map.

    Intended to be used for copy/cut text in magit buffers or in URLs with goto-address-mode enabled.

    default: nil

  • standard-keys-map-style

    The keymap style to use.

    Use this option to change the default keymap to use.

    default: 'standard-keys-default-keymap

Troubleshooting

  • The copy and cut commands (C-c, C-x) doesn’t work well in magit or with goto-address-mode.

    This is a common bug, standard-keys-mode provides the variable standard-keys-override-C-x-and-C-c-commands as workaround, which is disabled by default, you can set it to t for enable this.

  • The menu-bar command keybinding description is not updated.

    Currently there is not a possible workaround, but as an alternative, the marginalia package provides detailed information about the commands keybindings.

  • I cannot rebind C-g properly

    It is not possible to remap C-g properly.

    Although solutions such as this can be used:

(keymap-unset standard-keys-default-keymap "C-g")
(keymap-set standard-keys-default-keymap "ESC" (standard-keys-key-keybinding "C-g"))

The emergency quit (typing C-g once or many times) is hardcoded in Emacs C source code and cannot be changed.

So, when Emacs gets stuck, pressing the remaped C-g (e.g. ESC) will not quit from current loop.

Alternatives

A minor-mode that aims to:

  • Use/Create ergonomic keybindings in emacs that will reduce RSI
  • Use the commonly bound keys familiar to most people today. Ctrl+C for copy, Ctrl+z for undo, etc.

ergoemacs is very opinated, from my experience, it is hard to customize and use, the documentation is very outdated, and does not work properly in recent versions of Emacs.

But if you don’t care about this, you can try it.

CUA mode is a global minor mode. When enabled, typed text replaces the active selection, and you can use C-z, C-x, C-c, and C-v to undo, cut, copy, and paste in addition to the normal Emacs bindings. The C-x and C-c keys only do cut and copy when the region is active, so in most cases, they do not conflict with the normal function of these prefix keys.

cua-mode doesn’t include the classic commands that you may expect: C-o (Open), C-s (Save), C-f (Search), etc; so you will probably have to invest time in configuring it.

However cua-mode mode includes some features you may be interested in (e.g. cua-enable-cursor-indications, cua-toggle-rectangle-mark, etc).

Emacs minor mode that provides a modern, efficient and easy to learn keybindings. This mode makes it easy to pick up Emacs and start unlocking its potential without having to sacrifice its power. The point of this mode it to leverage common shortcuts that you are used to while making it easy to learn Emacs.

wakib-keys was the inspiration for package.

Like standard-keys-mode, wakib rebinds the C-x/C-c prefixes to C-e/C-d respectively. However wakib has been somewhat outdated, with some bugs in recent versions of Emacs.

If you are using an older Emacs version (prior 29.x), you can use wakib-keys instead of standard-keys-mode.


Thanks to Abdulla Bubshait (darkstego) for creating wakib-keys, which was the inspiration for this package.

About

Emulate standard keybindings from modern editors

Topics

Resources

License

Stars

Watchers

Forks