#-DESCRIPTION: An ergonomic keybinding for emacs
#+o_blog_row_column 4
<a href=”{lisp}(ob:path-to-root){@@html:@@lisp}/features.html”>/icon-cog icon-white Features
/icon-group icon-white/ Google Group
/icon-github-sign icon-white/ Github
<a href=”{lisp}(ob:path-to-root){@@html:@@lisp}/testimonials.html”>/icon-comments-alt icon-white Testimonials
<a href=”{lisp}(ob:path-to-root){@@html:@@lisp}/changelog.html”>/icon-pencil icon-white Changelog
<a href=”{lisp}(ob:path-to-root){@@html:@@lisp}/bug-report.html”>/icon-fire icon-white Bug report
First you need to install Emacs. Then you have 2 ways to install ergoemacs-mode.
#+o_blog_row_column 6
Start by cloning the main branch git repository from Github
cd ~/.emacs.d
git clone -b master --single-branch https://github.com/ergoemacs/ergoemacs-mode.git
And add following to your ~/.emacs
or ~/.emacs.d/init.el
file:
(add-to-list 'load-path "~/.emacs.d/ergoemacs-mode")
(require 'ergoemacs-mode)
To enable emacs, add the following to your ~/.emacs
or ~/.emacs.d/init.el
file:
(setq ergoemacs-theme nil) ;; Uses Standard Ergoemacs keyboard theme
(setq ergoemacs-keyboard-layout "us") ;; Assumes QWERTY keyboard layout
(ergoemacs-mode 1)
For other key themes and keyboard layouts the initilization code should be different. However, for QWERTY, the key bindings are:
file:ergoemacs-extras/ergo-layouts/ergoemacs-layout-us.png
Documentation Copyright © 2007-2016 Matthew Fidler, Xah Lee and David Capello. Published under the therm of the Creative Commons Attribution-Noncommercial-Share Alike 2.0 France License. Code published under GPL v3.
This page explains how ergoemacs-mode works. It was written in emacs org-mode and exported to HTML using o-blog.
- <a href=”{lisp}(ob:path-to-root){@@html:@@lisp}/features.html”>/icon-cog icon-white Features
- /icon-book icon-white/ Documentation
- Included Key Themes and Keyboard Layouts
- Preserving Emacs Commands while maintaining familiar shortcuts
- Key Themes
- Keyboard Layouts
- Changes to Modes
- Design Basis
- FAQ
- Bug report
- /icon-file icon-white/ Tips
- Gradual Adoption
- System Wide Keys
- Customizing your keys
- Making Commands Easier to Type
- Smart Commands
- <a href=”{lisp}(ob:path-to-root){@@html:@@lisp}/testimonials.html”>/icon-comments-alt icon-white Testimonials
- <a href=”{lisp}(ob:path-to-root){@@html:@@lisp}/changelog.html”>/icon-pencil icon-white Changelog
- <a href=”{lisp}(ob:path-to-root){@@html:@@lisp}/roadmap.html”>/icon-tasks icon-white Roadmap
- <a href=”{lisp}(ob:path-to-root){@@html:@@lisp}/index.html”>/icon-home icon-white {lisp}(ob:gettext :home){/lisp}
- <a href=”{lisp}(ob:path-to-root){@@html:@@lisp}/testimonials.html”>/icon-comments-alt icon-white Testimonials
- <a href=”{lisp}(ob:path-to-root){@@html:@@lisp}/changelog.html”>/icon-pencil icon-white Changelog
- <a href=”{lisp}(ob:path-to-root){@@html:@@lisp}/roadmap.html”>/icon-tasks icon-white Roadmap
The current changelog is here.
The historic changelog is below:
There are many changes that were missed, but will be added to this changelong in future releases. The biggest change for this release is movind to o-blog to generate HTML and changing `variants’ to `themes’. I believe that theme is easier to understand.
some minor fix to prevent byte compile errors.
to be documented later.
also, the commands “ergoemacs-forward-block” and “ergoemacs-backward-block” improved. Now they skip empty lines with whitespace in them properly.
A rewrite of the mode, with the following user-visible changes and features:
Call “ergoemacs-extras” to generate diagrams in SVG format for all supported layouts.
The files are generated at the `user-emacs-directory’ e.g. 〔~/.emacs.d/ergoemacs-extras/〕.
SVG files can be viewed in InkScape or modern browser (Firefox, Google Chrome, IE9, …).
for System-wide ErgoEmacs keybinding on Microsoft Windows.
Call “ergoemacs-extras” to generate AutoHotkey source code.
for ErgoEmacs keybinding for unix terminal.
Call “ergoemacs-extras” to generate.
To install, follow the instructions in the generated file.
for system-wide ErgoEmacs keybinding or Mac. Call “ergoemacs-extras” to generate.
To install, follow the instructions in the generated file.
You can customize keys by calling emacs’s “customize-group” then give it “ergoemacs-mode”.
Here’s some technical description:
- Added the customizable variable `ergoemacs-variable-layout’ which defines keys based on the QWERTY layout. You can customize this variable to suit your needs. Also you can save your customization so that You do not have to learn new keys every time a new ergoemacs mode is introduced.
- Added the customizable variable `ergoemacs-fixed-layout’ which defines keys that are the same regardless of the layout. This includes standard keys such as 【Ctrl+s】 for saving. For this layout I added 【Ctrl+z】 for undo, 【Ctrl+Shift+z】 for redo, 【Ctrl+y】 for redo
- Added the customizable variable `ergoemacs-minor-mode-layout’. From this variable all of the minor mode and major mode hooks are created and setup. When using `minor-mode-overriding-map-alist’ as the keybinding to modify, an additional keybinding variable is created per mode.
If you wish to freeze your keybindings, but keep current with the ergoemacs trunk, you can save all of the customizable variables and your layout will be saved between upgrades.
The internal working of the mode for mapping commands to keys has completely changed.
Now, each layout are defined using visual diagram similar to ASCII-art. This allows developers to easily add new layouts or change keys.
See 〔_README.txt〕 file that describes the tech detail of how layout format to be read by ErgoEmacs emacs lisp code.
The command for cancel “keyboard-quit” is changed from QWERTY 【Alt+n】 to 【Esc】. Reason: I think it’s overall slightly better, because: ① it’s more familiar. ② involves a single key. The disadvantage is that on terminal, Meta can no longer be pressed by 【Esc】 (but can still be done by 【Ctrl+[】). I think Esc for Meta is really bad, from the 1980s. I think it’s rare to find a terminal app today that do not support Alt as Meta.
Added functions: “cut-line-or-region” “copy-line-or-region”
Replacing previous “defadvice” functions: “kill-region-key” “kill-ring-save-key”
because these “defadvice” functions causes emacs to spit this warning “ad-Orig-kill-region called with 3 arguments, but accepts only 2”, since about emacs 24. Haven’t looked into why it’s doing that.
removed a bad code: (eval-when-compile (log-edit-mode)) there’s no function “log-edit-mode”.
Added commands “unfill-paragraph”, “unfill-region”. These are useful when doing keyboard macros. (in addition to “compact-uncompact-block”)
Modified forward/backward bracket functions (e.g. “backward-open-bracket”) so that they don’t print a error when reaching end.
• Added a French layout support. • Added 【Alt+6】 for “select-current-block”. Experimental. • Added 【Alt+7】 for “select-current-line”. Experimental.
• 【Alt+Shift+u】 was “beginning-of-defun”, is now “backward-block” • 【Alt+Shift+o】 was “end-of-defun”, is now “forward-block”
Rational: after tried the beginning/end of defun, i didn’t find it as usable in comparison to backward/forward block. Because, in many modes such as python, HTML, plain text (email, irc, text document), the defun one is useless. However, the move by block is applicable to vast majority of modes.
I think the navigation of defun and sexp has one nice key group. e.g. Ctrl+Alt+arrow move by sexp, and Ctrl+Alt+home/end does defun. So, that’s a nice set there.
Before, 【Alt+‹left/right›】 move cursor backward/forward to left bracket positions, and, 【Alt+‹up/down›】 does the same to right bracket positions.
Now, 【Alt+←】 does “backward-open-bracket”, and 【Alt+→】 does “forward-closing-bracket”. Now, 【Alt+↑】 and 【Alt+↓】 does backward/forward block.
A “block” is text between empty new lines. (similar to emacs’s “paragraph”)
Rational: Several advantages with the new way.
① reduces the number of keys needed for navigating to all possible left/right bracket points. Before, it needs 4 keys, now 2.
② the new way is more intuitive with emacs. The forward key moves to end of things, and backward to beginning of things.
③ advantage of backward/forward block: GNU Emacs has {【Ctrl+↑】, 【Ctrl+↓】} for backward/forward paragraph. The problem is that “paragraph” is dependent on major mode’s syntax table, so the behavior is unpredictable, and “paragraph” isn’t well defined in computer language modes. e.g. in “html-mode”, it seems to move in funny way. The new behavior is predicable and useful. It’s useful because vast majority of text uses empty lines to separate blocks of text.
Major change.
• 【Alt+Shift+j】 was “beginning-of-buffer”, is now “backward-open-bracket” • 【Alt+Shift+l】 was “end-of-buffer”, is now “forward-close-bracket”
• 【Alt+Shift+u】 was “backward-paragraph”, is now “beginning-of-defun” • 【Alt+Shift+o】 was “forward-paragraph”, is now “end-of-defun”
Rational: the beginning/end of buffer command is not frequently used. Their replacement, the backward/forward bracket is much more useful in any programing language with brackets: (){}[].
Similarly, the movement by defun is probably more useful than movement by paragraph, because most emacs users are programers. The concept of “paragraph” isn’t well defined in programing languages. But the defun movement also work with C-like syntax languages as well as lisp.
Thanks a lot to David Capello for suggestion and discussion. See: http://dacap.com.ar/programming/keyboard-layout/
〈Comandos de programación básicos de Emacs (forward-sexp, beginning-of-defun)〉 @ http://youtu.be/BuxJesmNc64
Also, implementation of {forward-open-bracket, backward-open-bracket, forward-close-bracket, backward-close-bracket} is reverted to not dependent on syntax table. Because, for example, in cperl mode, the curly bracket {} doesn’t have bracket syntax.
improved implementation of forward-open-bracket, backward-open-bracket, forward-close-bracket, backward-close-bracket
They now include the straight double quote char (Unicode U+22) Part of the new implementation are now based on syntax table. Not sure this is a improvement, because depending on syntax table makes the command unpredictable.
This is experimental change.
“forward-open-bracket” 【Alt+→】 “backward-open-bracket” 【Alt+←】 “forward-close-bracket” 【Alt+↓】 “backward-close-bracket” 【Alt+↑】
Note: other minor modes may over-ride these keys. e.g. “org-mode”.
These commands currently don’t have a key. You may bind the keys for “forward-paragraph” and “backward-paragraph”. Call “describe-function” on “forward-block” for detail.
Added: “select-current-line” “select-current-block”
Modified “select-text-in-quote” to also work on single quotes. e.g. ‘some thing’
just like emacs on linux’s default behavior. Rational: This is better than the 【Alt+a】. Because 【a】 is pinky, and it involves 2 keys. Now it’s single key. Also, this makes it compatible with emacs on linux .
, instead of 【;】. Rational: this is a highly frequently used command. 【;】 is on home-row, but by pinky. 【y】 is far, but by strong finger. Reaching for y may be a fraction of second slower, but more comfortable and healthy than using pinky.
(was “search-forward”) Feature incomplete. Need to add repeated 【Ctrl+f】 to invoke next match.
【F1 1】 describe-function 【F1 2】 describe-variable 【F1 3】 describe-key 【F1 4】 describe-char
【F1 6】 lookup-all-dictionaries 【F1 7】 lookup-google 【F1 8】 lookup-wikipedia 【F1 9】 lookup-word-definition 【F1 0】 lookup-answers.com 【F1 [】 lookup-word-dict-org 【F1 ]】 lookup-wiktionary 【F1 `】 elisp-index-search
【F2】 ,cut 【F3】 ,copy; 【Ctrl+F3】 ,copy-all 【F4】 ,paste
【F5】 ,undo; 【Ctrl+F5】 ,redo
【F8】 ,ctl-x-map. Emacs’s C-x prefix key.
Rational: these are single key or single key sequence additional keys. The copy, cut, paste, undo, ones are frequently used. Single key is good. The F8 is a additional key for emacs combo key C-x. The F1 key sequences adds many convenient or helpful commands.
added 【F1+m】 for “describe-major-mode” and 【F1+o】 for “where-is-old-binding”. Rationale: keep in sync with the 【F1】 = 【Ctrl+h】 equivalence.
rationale: Close Current Window should really follow OS’s key convention. Or, in ErgoEmacs, 【Alt+F4】 does it. This way, it’s more standard. Less keys.
On the Mac, current behavior is ok too.
The reason for a 【Ctrl+Shift+w】 for closing window doesn’t seem strong.
Fixed bug #92 http://code.google.com/p/ergoemacs/issues/detail?id=92 Previously, it prompt if user want to save, etc. Thanks to dek1999@live.com
Fixed “open-in-external-app”. Before, on linux, emacs freezes until external app is closed. Thanks to Thanks to Ozan Erdem.
trivial changes.
updated a few files that points to the dead 〔http://tecladobrasileiro.com.br/〕 to 〔http://xahlee.org/kbd/pt-nativo_keyboard_layout.html〕
2012-03-03 Added a command “open-in-external-app”. The key 【Ctrl+Shift+o】 is now bound to it, instead of “open-in-desktop”.
Originally, it’s unbound because the thought was that 【Ctrl+o】 for “find-file” with a dir input is a good clean substitute. But now, i think in some situations, calling dired directly is necessary. For example, calling dired then give “~/emacs/*.html” to list all HTML files. If using “find-file”, it’ll try to open all files.
Now, since it’s necessary to call “dired” directly sometimes, it’s convenient to have a key. Since GNU Emacs already has 【C-x d】 for it, and this key doesn’t conflict with ErgoEmacs, so we use it.
Thanks to Joseph Buchignani 〔 http://www.cyborganize.org/clarity/software/emacs-org-mode-installation-configuration-and-tutorial/installing-and-using-ergoemacs-for-intermediate-emacs-users/ 〕 and Jon Snader 〔 http://irreal.org/blog/?p=365 〕.
r647 Fixed a bug http://code.google.com/p/ergoemacs/issues/detail?id=91 with a default GNU Emacs, when cua-mode is NOT turned on, load ergoemacs-mode and turn it on, then keys with Shift will also highlight text. This is because ergoemacs-fix-cua–pre-command-handler-1 tries to set symbols from cua-mode but they are not there.
thanks to (zyangm…@gmail.com) for bug report.
fixed by temp turning on cua-mode.
Added a ergoemacs-auto-complete-mode-hook. http://code.google.com/p/ergoemacs/source/detail?r=638
Thanks to Renier (renierm@gmail.com) for code. http://groups.google.com/group/ergoemacs/msg/f5f9337e34b4eab3?hl=en
r556 This key follows browser convention. But won’t work in Terminal.
r578. Thanks to Max Arnold for bug report.
Added Danish layout. Thanks to Michael Budde Added ergoemacs-layout-pt-nativo.el. Thanks to Xavier Pinho
You can see all supported layouts and their contributors in the directory 〔ergoemacs-keybindings〕.
See also: 〈Dvorak, Maltron, Colemak, NEO, Bépo, Turkish-F, Keyboard Layouts Fight!〉 @ http://xahlee.org/kbd/dvorak_and_all_keyboard_layouts.html
This is a standard key together with 【Ctrl+Arrow】 and 【Ctrl+Del】.
r477 Technically, removed the unbinding of 「<C-backspace>」
A bug fix. Thanks to Jorge Dias.
Contributed by Kristian Hellquist.
OLD COMMAND NEW 【Alt+1】 delete-other-windows 【Alt+3】 【Alt+!】 delete-window 【Alt+0】 【Alt+2】 split-window-vertically 【Alt+4】 【Alt+@】 split-window-horizontally 【Alt+$】
Reason: the 1 and 2 keys are two of the most difficult to press keys on the top row. 3 and 4 are the best for left hand. 8 and 9 are the best for right hand. (this can be verified by looking at the original Dvorak layout for number keys)
For emacs commands, according to command frequency statistics, the order are roughly this, from most used to least:
delete-other-windows split-window-vertically delete-window split-window-horizontally
therefore this change. For Xah Lee’s personal experience in this, see: http://xahlee.org/emacs/vi_esc_syndrome.html
Note that 【Alt+0】 for delete-window was in the original ErgoEmacs keybinding design for about a year, but got changed to 【Alt+Shift+1】 (【Alt+!】). The thinking was for some logical consistency with 【Alt+1】. My experience since is that logical consistency is bad for ergonomics advantage. Logical consistency is good at beginning for learning, but once muscle memory is developed, ergonomic efficiency is far more important, and will be used for years.
【Ctrl+p】 will now ask user confirmation before printing the current buffer. This is to prevent unintentional printing. Old Emacs users tends to press 【Ctrl+p】 a lot because that used to be moving cursor up. See: http://code.google.com/p/ergoemacs/issues/detail?id=60
Thanks to Jorge Dias (aka theturingmachine) http://code.google.com/p/ergoemacs/source/detail?r=371 http://groups.google.com/group/ergoemacs/browse_frm/thread/3e1b9326b6cc2cc4
Thanks to Phillip Wood http://code.google.com/p/ergoemacs/issues/detail?id=73
by David Capello. (and thanks to maddin)
Added ergoemacs-hook-list variable, ergoemacs-add-hook function, and ergoemacs-global/local-set/unset-key functions
and added “defadvice” for local/global-set/unset-key functions. http://code.google.com/p/ergoemacs/source/detail?r=369 http://code.google.com/p/ergoemacs/issues/detail?id=67#c3
Added a feature so that copy/cut will get the current line if there’s no text selection.
Italian layout has been created, by By David Capello, with help by Francesco Biccari
A Colemak layout is added or sometimes before. The bulk of key mapping was helped by Ivan Haralamov (aka postivan), and vockets?
By David Capello. This version is now a full featured minor mode. It supports 3 different keyboard layout: US QWERTY, US Dvorak, and “Spanish (Spain)” (aka “Spanish (International sort)”). Also supports a new command where-is-old-binding (with shortcut 【Ctrl+h o】).
improved shrink-whitespaces. Now, when called twice, it removes the remaining single space. Thanks to David Capello for the code.
Fixed a bug where delete-selection-mode might be turned off. Changed “(delete-selection-mode t)” to “(delete-selection-mode 1)”.
A minor implementation improvement. In one place, changed the use of functionp to fboundp for checking the existing of a emacs 23 feature recenter-top-bottom. Was using functionp because i forgot about fboundp.
diff-mode uses some bindings in “M-‹key›” space. Fixed by adding a diff-mode-hook. (thanks to lwarxx)
ibuffer’s 「M-s」 changed in emacs 23, such that 「M-s」 is now a prefix. For Dvorak users, 「M-s」 should be isearch. This is reclaimed to be isearch. For qwerty users, 「M-s」 should be other-window. Fixed.
dired’s 「M-s」 changed in emacs 23, such that 「M-s」 is now a prefix. For Dvorak users, 「M-s」 should be isearch. This is reclaimed to be isearch. For qwerty users, 「M-s」 should be other-windox. Fixed.
Added 【Alt+Shift+PageDown】 for forward-page (move cursor to the next ASCII formfeed char (often displayed as ^L)). Same for PageDown key.
Added 【Ctrl+Shift+n】 for opening a new window (make-frame-command). Removed 「C-x 5 2」. Added 【Ctrl+Shift+w】 for closing window (delete-frame), removed 「C-x 5 0」.
A better implementation for making 「M-t」 call 「M-TAB」. So that, describe-key on M-t will show better documentation.
Changed the keybinding for previous-user-buffer from 【Ctrl+←】 to 【Ctrl+PageUp】. And previous-emacs-buffer from 【Ctrl+Shift+←】 to 【Ctrl+Shift+PageUp】. Similar for the “next” versions. Rationale: The 【Ctrl+Arrow】 are standard editing shortcuts command in Windows, Mac, Linux.
Added 【Alt+t】 for keyword completion. Rationale: The default 「M-TAB」 is used by Windows, Mac, Linux, to switch apps.
Corrected the keybinding for Save As (write-file)
Made compact-uncompact-block to work on text selection if there’s one.
Sometimes when closing a buffer not associated with a file, it’ll prompt whether to kill instead of whether to save.
It now works non-english letters such as éÉ and single letter word “a teapot” or words starting with a number “1st timer”. Thanks to Andreas Politz and Nikolaj Schumacher.
Because they are defined in ourcomments-util.el bundled with emacs 22, also because they are not used in this file now (compact-uncompact-block replaced most of their functionality).
previous-user-buffer, next-user-buffer, next-frame-command, previous-frame-command, query-replace and query-replace-regexp, move-cursor-to-next-pane, move-cursor-to-previous-pane, split-window-horizontally, toggle-letter-case. Combined delete-blank-lines and just-one-space to shrink-whitespaces.
Fixed cua-mode-hook by setting symbol property ‘CUA to nil, so that a bunch of no-select-* functions kludge is no longer needed. Thanks to Lennart Borgman.
Moved cua fix functions to modern_operations.el. The functions are: no-select-cua-scroll-down, no-select-cua-scroll-up, no-select-backward-paragraph, no-select-forward-paragraph, no-select-beginning-of-buffer, no-select-end-of-buffer, no-select-move-end-of-line.
Currently ergoemacs-mode:
- Changes the default emacs keybindings in two ways:
- To be more ergonomic by binding frequently used commands to easy to reach keys
- Implement standard keyboard shortcuts in emacs.
- Allows keyboard themes for:
- Gradual ergoemacs-adoption
- Backward Compatability
- Ergonomic personalization
Here’s the outline of how this design is arrived.
Statistics of emacs commands are compiled from emacs users, and are listed by frequency of use. The top about 30 ones, are given a keyboard shortcut.
To assign the key position, the following rules are used. The rules are listed roughly in order of priority:
- Home row keys are the best.
- 2nd and 3rd fingers (pointing finger and index finger) are better than 4th (ring finger) and 5th finger (pinky).
- The row above home row is considered better than the row below home row for 2nd and 3rd fingers. (for 5th finger the row below is considered better.)
- Right hand’s keys are considered better than left hand’s keys. (because most people are right handed)
- Alt is considered better than Ctrl. (@@html:<kbd class=”dark”>@@Alt is a natural thumb curl, Ctrl is stretched pinky. Thumb is most powerful finger, pinkie the weakest)
- In general, cursor moving commands are placed all for the right hand, while text changing commands are all placed for the left hand. (grouping advantage)
- Similar commands should be grouped together to avoid scattering. For example, cursor moving by single char is together (I J K L). Undo, Cut, Copy, Paste are together (Z X C V). Delete char/word left/right are together (E R D F).
- Commands with logical reversal or extension are done with ⇧ Shift key, after other priorities are considered. Examples: Undo/Redo, move cursor to previous/next pane, find replace by string/regex, isearch forward/backward, move cursor by beginning/ending of line. Delete line to the right/left.
The design is based on finger positions, not on first letter of command names. The shortcut set is the same for QWERTY and Dvorak. The ease of remembering what commands are on what keys are based on grouping and positioning. For example, cursor movings are all right hand, text changing are all left hand, moving or deleting to the left/right have keys that are place left and right together, and similar for up/down (by screen or to beginning/end of file). Undo, Cut, Copy, Paste are the familiar row Z X C V.
In this design, only the Alt+‹key› space is used. Some Alt+⇧ Shift is used too. Ctrl+‹key› space is not used except 7 standard keybindings (Open, Close, Save, Save As, Print, Select All). The operation and consistency of emacs is not affected.
This shows the standard shortcuts implemented in ergoemacs:
Standard Name | Ergoemacs-key | Emacs Key | Emacs Command Name |
---|---|---|---|
Copy | Ctrl+c | Alt+w | kill-ring-save |
Cut | Ctrl+x | Ctl+w | kill-region |
Paste | Ctrl+v | Ctrl+y | yank |
Undo | Ctrl+z | Ctrl+_ or Ctrl+/ | undo |
Redo | Ctrl+⇧ Shift+z or Ctrl+y | NA | redo |
Open New File | Ctrl+n | NA | Not builtin |
Open | Ctrl+o | Ctrl+x Ctrl+f | find-file |
Ctrl+p | NA | ||
Select All | Ctrl+a | mark-whole-buffer | |
Find | Ctrl+f | Ctrl+s | search-forward |
Standard shortcuts for cursor navigation are also supported. For example:
- Ctrl+← ⇒ move cursor to to previous word.
- Home ⇒ move cursor to beginning of
- Shift+↓ select text downward.
There is a conflict between standard shortcuts and emacs shortcuts. In most applications Ctrl+c is copy and Ctrl+x is cut. In emacs Ctrl+x generally refer to global commands, while Ctrl+c refers to language specific commands.
Ergoemacs provides a few options to work with the Ctl+c and Ctl+x keys.
Like cua-mode
, ergoemacs-mode
allows Ctrl+c and Ctrl+x to be
bound to both copy/cut, and the emacs key sequences.
The default method will copy text when selected with Ctrl+c and cut text when selected with Ctrl+x. This is fine, but if you wish to perform an emacs command on selected region, this could be problematic as discussed in Xah’s blog. (For example python shift indent is bound to 【Ctrl+c <】)
When you wish to do issue emacs commands on a region you can:
- Add a shift to the first Ctrl+c and Ctrl+x.
- For example press 【Ctrl+⇧ Shift+c <】 for python’s shift indent command
- This will not work in a terminal (most terminals cannot tell the difference between 【Ctrl+⇧ Shift+c】 and 【Ctrl+c】)
- Press the next key within 0.2 seconds.
- This can be tuned by setting
ergoemacs-ctl-c-or-ctl-x-delay
- If you tune this to a higher setting, it takes longer to copy and cut and other problems may be introduced.
- This can be tuned by setting
If you wanted the time required to press the next key be 1 second, you could use the following in your emacs startup file:
(setq ergoemacs-ctl-c-or-ctl-x-delay 1)
Another option is to ditch copy and paste with Ctrl+c and Ctrl+x, even though they are standard keys. Instead you can use Alt+c and Alt+x to do copy and paste.
This can be done in ergoemacs by the following variable:
(setq ergoemacs-handle-ctl-c-or-ctl-x 'only-C-c-and-C-x)
The disadvantage to this approach is that you use different keys in different applications.
If you wanted Ctrl+c and Ctrl+x to only be copy and cut, you add the ability to copy/cut the current line when nothing is selected. This can be done by:
(setq ergoemacs-handle-ctl-c-or-ctl-x 'only-copy-cut)
The possible disadvantage to this is you would have to use another key to access the defined emacs commands. Currently ergoemacs-mode allows you to use QWERTY 【▤ Menu d】 or 【Ctrl+⇧ Shift+x】 to access emacs Ctrl+x commands and QWERTY 【▤ Menu f】 or 【Ctrl+⇧ Shift+c】 to access Ctrl+c commands.
The 【▤ Menu】 keybindings are slightly different than plan Ctrl+x or Ctrl+c:
- For Ctrl+x, the Alt and Ctrl keys are swapped. Hence for the equivalent of 【Ctrl+x Ctrl+b】, you would press 【▤ Menu s Alt+b】
- For Ctrl+c, control keys are mapped to plain keys. Plain keys
are mapped to Alt keys. Alt keys are mapped to Ctl keys. Hence:
- 【Ctrl+c Ctrl+c】 would be 【▤ Menu f c】
- 【Ctrl+c c】 would be 【▤ Menu f Alt+c】
- 【Ctrl+c Alt+c】 would be 【▤ Menu f Ctl+c】
- This is called unchorded mapping
- You can swap between Normal, Alt<->Ctl and unchorded keyboard translations in ergoemacs by pressing 【▤ Menu】
To use key theme and layout, use the following in your .emacs
or
.emacs.d/init.el
.
#+ATTR_HTML :id dot_emacs
(setq ergoemacs-theme nil)
(setq ergoemacs-keyboard-layout "us")
(ergoemacs-mode 1)
Emacs has its own methods to set keys globally. Ergoemacs-mode attempts to honor this.
Key themes are a big part of the new ergoemacs-mode. These allow more than one keyboard binding to be packaged but still use the ergoemacs-mode engine. This allows:
- Gradual ergoemacs-adoption
- Backward Compatability
- Sharing of your personalized ergoemacs-theme
- Keeping ergoemacs compatibility fixes such as:
- Using the arrow keys in the terminal when Alt+O or Alt+o is bound
- Providing fixes for known minor and major modes so they respect the ergonomic keyset.
- Keeping some additional ergoemacs features like:
- Applying your personalied ergoemacs-theme everywhere
You can manually code your own ergoemacs theme. I am currently working on a simlper method to theme keys.
All the layouts in ergoemacs are easy to generate. To add your own
personal layout you just need to match the keybindings for your in a
layout variable from ergoemacs-layout-XXX
. For the US and UK
layouts, the defining variable adds the layout:
(defvar ergoemacs-layout-us
'("" "`" "1" "2" "3" "4" "5" "6" "7" "8" "9" "0" "-" "=" ""
"" "" "q" "w" "e" "r" "t" "y" "u" "i" "o" "p" "[" "]" "\\"
"" "" "a" "s" "d" "f" "g" "h" "j" "k" "l" ";" "'" "" ""
"" "" "z" "x" "c" "v" "b" "n" "m" "," "." "/" "" "" ""
;; Shifted
"" "~" "!" "@" "#" "$" "%" "^" "&" "*" "(" ")" "_" "+" ""
"" "" "Q" "W" "E" "R" "T" "Y" "U" "I" "O" "P" "{" "}" "|"
"" "" "A" "S" "D" "F" "G" "H" "J" "K" "L" ":" "\"" "" ""
"" "" "Z" "X" "C" "V" "B" "N" "M" "<" ">" "?" "" "" "")
"US Engilsh QWERTY Keyboard")
(defvar ergoemacs-layout-gb
'("" "`" "1" "2" "3" "4" "5" "6" "7" "8" "9" "0" "-" "=" ""
"" "" "q" "w" "e" "r" "t" "y" "u" "i" "o" "p" "[" "]" ""
"" "" "a" "s" "d" "f" "g" "h" "j" "k" "l" ";" "'" "#" ""
"" "\\" "z" "x" "c" "v" "b" "n" "m" "," "." "/" "" "" ""
;; Shifted
"" "¬" "!" "@" "#" "$" "%" "^" "&" "*" "(" ")" "_" "+" ""
"" "" "Q" "W" "E" "R" "T" "Y" "U" "I" "O" "P" "{" "}" ""
"" "" "A" "S" "D" "F" "G" "H" "J" "K" "L" ":" "@" "~" ""
"" "|" "Z" "X" "C" "V" "B" "N" "M" "<" ">" "?" "" "" "")
"UK QWERTY")
This lists the keyboard positions from left to right for the unshifted and shifted states of he keyboard. After listing the keyboard descriptions it provides a description of the layout which is used for the customization variable `ergoemacs-keyboard-layout’. By simply defining your layout before ergoemacs-mode is loaded, you add it to the ergoemacs-keyboard-layout variable with its description.
If you have generated a keyboard layout that ergoemacs-mode does not yet support please drop me a line.
Most major and minor modes are setup to respect ergoemacs-mode
keybindings. There are additional changes described below
Ergoemacs-mode in general respects org-mode’s Ctrl+Enter and Alt+arrow keys. The following exceptions are of note:
In org-mode tables Ctrl+enter activates cua rectangle mode. The paste knows what was copied, and will use cua-mode, or org-mode’s default pasting mechanism depending on if a rectangle was copied last.
The alt+arrow keys are respected based on context for org-mode. When in text, you can use the ergoemacs-mode defined key, or the org-mode defined key by changing the value of a few variables
Key | Variable to Enable ergoemacs function in org-mode text | Enabled by default |
---|---|---|
<M-left> | ergoemacs-use-ergoemacs-metaleft | yes |
<M-right> | ergoemacs-use-ergoemacs-metaright | yes |
<M-up> | ergoemacs-use-ergoemacs-metaup | no |
<M-down> | ergoemacs-use-ergoemacs-metadown | no |
The values of these variables could be changed by:
(setq ergoemacs-use-ergoemacs-metaleft nil)
Cua mode is not enabled by default, but ergoemacs-mode can use some of its features. To enable CUA rectangles, use:
(cua-selection-mode t)
If cua-mode
is enabled before ergoemacs-mode
is loaded,
ergoemacs-mode
changes to cua-selection-mode
. If you attempt to
enable cua-mode
, only cua-selection-mode
will be enabled.
CUA rectangle support is enabled by changing the Alt+ keys to Win+ keys.
If you do not know what CUA rectangles are, the following describes CUA rectangles and gives the keys used for ergoemacs-mode.
Cua-mode’s rectangle select region has bound it Emacs’s normal rectangle support is based on interpreting the region between the mark and point as a “virtual rectangle”, and using a completely separate set of “rectangle commands” [C-x r …] on the region to copy, kill, fill a.s.o. the virtual rectangle.
cua-mode’s superior rectangle support uses a true visual representation of the selected rectangle, i.e. it highlights the actual part of the buffer that is currently selected as part of the rectangle. Unlike emacs’ traditional rectangle commands, the selected rectangle always as straight left and right edges, even when those are in the middle of a TAB character or beyond the end of the current line. And it does this without actually modifying the buffer contents (it uses display overlays to visualize the virtual dimensions of the rectangle).
This means that cua-mode’s rectangles are not limited to the actual contents of the buffer, so if the cursor is currently at the end of a short line, you can still extend the rectangle to include more columns of longer lines in the same rectangle. And you can also have the left edge of a rectangle start in the middle of a TAB character. Sounds strange? Try it!
To start a rectangle, use [C-return] and extend it using the normal movement keys (up, down, left, right, home, end, C-home, C-end). Once the rectangle has the desired size, you can cut or copy it using C-x and C-c (or C-w and M-w), and you can subsequently insert it - as a rectangle - using C-v (or C-y). So the only new command you need to know to work with cua-mode rectangles is C-return!
Normally, when you paste a rectangle using C-v (C-y), each line of the rectangle is inserted into the existing lines in the buffer. If overwrite-mode is active when you paste a rectangle, it is inserted as normal (multi-line) text.
If you prefer the traditional rectangle marking (i.e. don’t want straight edges), [M-p] toggles this for the current rectangle, or you can customize cua-virtual-rectangle-edges.
And there’s more: If you want to extend or reduce the size of the rectangle in one of the other corners of the rectangle, just use [return] to move the cursor to the “next” corner. Or you can use the [M-up], [M-down], [M-left], and [M-right] keys to move the entire rectangle overlay (but not the contents) in the given direction.
[C-return] cancels the rectangle [C-space] activates the region bounded by the rectangle
If you type a normal (self-inserting) character when the rectangle is active, the character is inserted on the “current side” of every line of the rectangle. The “current side” is the side on which the cursor is currently located. If the rectangle is only 1 column wide, insertion will be performed to the left when the cursor is at the bottom of the rectangle. So, for example, to comment out an entire paragraph like this one, just place the cursor on the first character of the first line, and enter the following: C-return M-} ; ; <space> C-return
cua-mode’s rectangle support also includes all the normal rectangle functions with easy access:
[Win+a] aligns all words at the left edge of the rectangle [Win+b] fills the rectangle with blanks (tabs and spaces) [Win+c] closes the rectangle by removing all blanks at the left edge of the rectangle [Win+f] fills the rectangle with a single character (prompt) [Win+i] increases the first number found on each line of the rectangle by the amount given by the numeric prefix argument (default 1) It recognizes 0x… as hexadecimal numbers [Win+k] kills the rectangle as normal multi-line text (for paste) [Win+l] downcases the rectangle [Win+m] copies the rectangle as normal multi-line text (for paste) [Win+n] fills each line of the rectangle with increasing numbers using a supplied format string (prompt) [Win+o] opens the rectangle by moving the highlighted text to the right of the rectangle and filling the rectangle with blanks. [Win+p] toggles virtual straight rectangle edges [Win+P] inserts tabs and spaces (padding) to make real straight edges [Win+q] performs text filling on the rectangle [Win+r] replaces REGEXP (prompt) by STRING (prompt) in rectangle [Win+R] reverse the lines in the rectangle [Win+s] fills each line of the rectangle with the same STRING (prompt) [Win+t] performs text fill of the rectangle with TEXT (prompt) [Win+u] upcases the rectangle [Win+|] runs shell command on rectangle [Win+’] restricts rectangle to lines with CHAR (prompt) at left column [Win+/] restricts rectangle to lines matching REGEXP (prompt) [C-?] Shows a brief list of the above commands.
[M-C-up] and [M-C-down] scrolls the lines INSIDE the rectangle up and down; lines scrolled outside the top or bottom of the rectangle are lost, but can be recovered using [C-z].
In dired-mode, [Ctrl+c] [Ctrl+c] or [Apps] [m] will toggle to writable dired mode (wdired-mode). Then [Ctrl+c] [Ctrl+c] or [Apps] [m] will commit the changes.
Helm mode’s actions are in general executed with the Return key. The persistent actions can be executed with Alt+Return. The prefix-based persistent actions can be execute with Alt+Shift+Return.
The exception to this is when finding files. Return will expand the directory within helm (equivalent to helm’s execute persistent action for a directory). And Alt+Return will open dired. This is equivalent to ido-mode. In my opinion it is more likely that you want to do than to open in ido-mode. Therefore an unchorded key is more ergonomic than a key combination like Alt+Return. However, you can turn off this behavior by changing the following setting:
(setq ergoemacs-helm-ido-style-return nil)
When visual regexp is installed, ergoemacs-mode changes
query-replace-regexp
to vr/query-replace
The package browse-kill-ring
can be integrated into the way that
ergoemacs-mode pastes. For information see
smart commands.
Authors: Nikolay Kudryavtsev and Matthew L Fidler
Icicles is a complicated library with many different keybindings. Ergoemacs also has quite few keybindings of it’s own. Since both packages were originally developed separately it is understandable that there can be a conflict between them. This documentation lists the known cases of conflict.
Icicles uses M-p and M-n for `icicle-previous-history-element` and `icicle-next-history-element`. Since those are perfect examples of non-ergonomic keys, ergoemacs changes them to F11 and F12. This is consistent with changes to other packages.
In icicles you can insert an element from your minibuffer history, thus limiting your candidates only to the ones in your minibuffer history. In `ergoemacs-mode` This can be done by M-F11 or M-F12.
In the vanila icicles `icicle-previous-candidate-per-mode` and `icicles-next-candidate-per-mode` are cycled using C-p and C-n. This is not ergonomic, so in ergoemacs it was moved to M-i and M-k.
Whenever icicles binds a standard key like C-p or C-n, or C-s, ergoemacs-mode looks up the change and runs the mode-based changed key.
In icicles you can easily see all available keys using key completion. The default key for this is S-TAB for buffers and M-S-TAB for the minibuffer. Due to M-TAB being used by default by some window managers including Windows, ESC-S-TAB is also available by default. Since ESC works like C-g in ergoemacs, ESC-S-TAB binding would not work with it.
When icicles and ergoemacs-mode is enabled, pressing f1 in the key sequence will start the key completion.
Things here conflict with some ergoemacs keybindings, but can be easily fixed by the user.
The most basic ergoemacs theme component for icicles looks like this. Since most of the icicles keybindings are connected to minibufer, you should put your keybindings within “when `icicle-minibuffer-setup-hook`” form.
(ergoemacs-component ergoemacs-icicles-user ()
"Ergoemacs-mode theme component for icicles"
(when icicle-minibuffer-setup-hook
(define-key minibuffer-local-map (kbd "M-p") 'icicle-insert-history-element)))
(ergoemacs-require 'ergoemacs-icicles-user)
Icicles allows you to match only those candidates that have particular text within them. A rather complex example is available here.
C-M-h is a good candidate, since it’s close enough to the original key, but does not conflict with ergoemacs:
(define-key minibuffer-local-map (kbd "C-M-h") 'icicle-insert-list-join-string)
Before reporting a bug, please check if it is already known about.
Indeed, it may already have been fixed in a later release of
ergoemacs-mode
, or in the development version. Here is the issues
list: https://github.com/ergoemacs/ergoemacs-mode/issues
If you are able to, try the latest ergoemacs-mode
to see if the
problem has already been fixed.
To report a bug please be sure your issue is ergoemacs-mode
related.
An easy way to do that is to get a clean environment to see if you can
reproduce the error. If you can load ergoemacs, then this can be
accomplished by Alt+a ergoemacs-clean
.
Otherwise, this can be accomplished by
emacs -Q
Then in the *scratch*
buffer adding
(setq debug-on-error t) ; Activate debugging
(add-to-list 'load-path "/path/to/ergoemacs/")
(require 'ergoemacs-mode)
(setq ergoemacs-debug t)
(setq ergoemacs-keyboard-layout "us") ; Layout you use.
(setq ergoemacs-theme nil) ; For standard theme.
(ergoemacs-mode 1)
Then type Alt+x eval-buffer
.
See if you can reproduce the bug from this empty environment. If you
can reproduce the bug this way, that rules out bugs in your personal
customizations. Then your bug report should begin by stating that you
started Emacs with emacs -Q
, followed by the exact sequence of steps
for reproducing the bug. If possible, inform us of the exact contents
of any file that is needed to reproduce the bug.
When you hit an error, a *Backtrace*
buffer will appear on the
screen. Save this buffer to a file and attach it to your bug report.
Please report documentation bug too.
This page collects testimonial for ergoemacs-mode. Thank you. I appreciate them very much. Your nice words keep me going. – Xah Lee
After some 30 years of using Emacs constantly, I recently switched from using Microsoft keyboards (of various sorts) to using Apple keyboards. Needless to say, Emacs Pinky arose and I found myself consuming most all of what Xah Lee has written in the area of using Emacs ergonomically with Apple keyboards. Most impressive material.
Being a bleeding edge Emacs User (and occasional developer, although it embarrasses me to think about how long it has been since I made any substantial contributions), I use the development nightly builds as a matter of course. So when I bit the bullet and installed ErgoEmacs, my instance blew up (in that nothing worked as expected) and I decided to back off a bit from going whole hog. [Mea culpa, but I did not have the time to debug the problems. At least not yet.]
To make a long story shorter, I embraced the notion of remapping keys to use the recommended ErgoEmacs layout, but tried to shortcut the process by turning “caps lock” into a “menu” key and creating key sequences that were productive for me; remapping the “control” key to “command”, the “option” keys to “control” and the “command” keys to “option”. But I did not take the pains of programmatically changing the key bindings for other packages (like org-mode) so I quickly ran into hassles.
To resolve the issue of other package interference with the ErgoEmacs keybindings I used (on Meta), I switched back to using the Mac default modifier keys and mapped the ErgoEmacs bindings to the “command” keys via Super.
One of Xah’s best suggestions for me was the notion of “curled thumbs” to symmetrically type the Super keys. That has been a huge win, both in eliminating Emacs Pinky and improving my typing productivity. Who knew? :-)
I am still a bit anxious that OS X will intervene on some of my rebindings with the “command” key in particular but so far so good.
In all of this work that I’ve done, the major factor has been significantly reducing the need to use C-<key> and M-<key> chords and instead using “menu” key sequences and s-<key> chords.
Another factor has been standardizing on the short Apple keyboard (the one found on recent Apple laptops) which I once hated because of the lack of “control” key symmetry. I found that once I started using curled thumbs for chords, the short keyboard actually worked quite well for me. Especially since I use some half dozen MacBook Air/Pro laptops and Mac Mini systems on a regular basis.
There are probably a few other steps taken that I have forgotten but I think this captures most of a positive experience in embracing ErgoEmacs keyboarding.
fwiw,
-pmr
Thanks to @xah_lee for ergo-emacs. If #emacs could become my prime editor for windows, I would be exuberant!
- Emacs for the rest of us (Posted by macco)
- ErgoEmacs
- Ergoemacs Keybindings (2009-07-09 By Xichekolas)
Delicious.com bookmark site comments
I just spent three days trying out Xah Lee’s ErgoEmacs – ergonomic Emacs keybindings – and I’ve been impressed.
Xah Lee’s Ergoemacs is five different kinds of awesome.
Installing and using Ergoemacs
From: Don Womick Subject: [Orgmode] ErgoEmacs Date: Sat, 14 Aug 2010 09:07:58 -0400 I’ve just found ErgoEmacs (http://ergoemacs.org), another Emacs distribution for Windows that tries to make Emacs easy to use for ordinary users… and it does so: I was able to use it immediately, with all the standard Windows shortcuts–the only things that tripped me up briefly were the file commands (C-xf moved to C-o and C-xw moved to C-w), and that they moved M-x to M-a (M-x now cuts the entire line). This looks like a distro that might ease the learning curve enough to drive more widespread adoption of Emacs (and org-mode!): it really does seem to be as easy to use as Notepad right out of the box, yet doesn’t take away any of the power of Emacs (as far as I can tell, except that I did have to load an org-mode file before capture would work, but that may be a setup problem on my part). If you’re on Windows, take a look and see what you think… and for org newbies on win32, I think this is the version I would recommend.
–Don
lists.gnu.org emacs-orgmode
I started using ergoemacs last week, and it looks promising. It lacked a swedish keyboard layout though
Thanks for your great blog, work and opinions about emacs.
/Kristian Hellquist
Thanks to Kristian Hellquist for contributing a Swedish layout. It’s in ErgoEmacs Keybinding v5.3.4.
2009年11月4日星期三
ErgoEmacs 初探
一直以來,我都是從 Xah’s Emacs Tutorial 獲得一些 Emacs 使用上的小技巧。前幾天突然發現 Xah Lee 弄了一個專案 — ErgoEmacs。一個很有趣的專案,同時也是破壞 Emacs 傳統的專案。
Emacs 專屬的 keybindings 可以說是一項足以自豪的傳統。對於那些不使用滑鼠的高手來說,keybindings 一定背的滾瓜瀾熟。但非人使用 Emacs 超過十年了,熟悉的 keybindings 不會多過 10 個。並不是非人不想背下來,而是太複雜了,今天背了明天就忘了。再加上非人非常地依賴滑鼠,所以總是記不了幾個 keybindings。而 ErgoEmacs 這個專案主要就是在改變 keybindings,讓 Emacs 更能符合現代使用電腦的習慣。這個套件可以從這裡下載。
jeangjs.blogspot.com 非人的筆記本
I totally agree with the remap caps-lock solution, that helps quite a bit. To go even further, I tried and liked the Ergoemacs keybindings. The project is being actively developed, and supported quite well. I personally don’t use it because it’s not integrated with Mac OS X (some EMACS Keys are integrated in Cocoa), though it seems someone has posted an inputrc file with Ergoemacs keybindings. Another trick I’ve been playing with is enabling StickyKeys. It’s supported on many platforms and alleviates some of the problems specific to chording (as opposed to just overuse): it is apparently recommended on the emacswiki: http://www.emacswiki.org/emacs/StickyModifiers
I used to do the same thing, but I missed out on a lot of good emacs shortcuts. Today I use the dvorak version of Xah Lee’s layout. You get vim-like navigation by holding Meta.
— jroes Source news.ycombinator.com
(9:06:35 AM) laurus: Hello! I just wanted to let you know that I recently installed your Ergoemacs and I’m enjoying it very much.
fadec: I had customized my keybindings but someone suggested I try Ergoemacs a few weeks ago. Forget vim - ergoemacs is how it’s done.
freenode irc chat:
Ghoul“: xah_lee: i appreciate the ergonomic emacs shortcuts especially M-x being M-a right now ☺ however only one thing is weird.. the M-; for searching (M-s in dvorak) but if i want to go to the next entry i press C-s and not M-; again; that’s like the only tiny thing; otherwise i really like and use all the other shortcuts; really good stuff!
freenode irc chat:
ginstre: i’m an avid user of your ergonomic keybindings. one small suggestion: the isearch-mode-map bindings should be copied to the minibuffer-local-isearch-map. otherwise one can’t resume an isearch that has been modified (⁖ by M-n, M-p or isearch-edit-string).
From w k
你好,偶然访问李杀网,从你的网站发现非常有价值的emacs教程。尤其关于人体工程力学的键位设置及键盘推荐,更是出类拔萃,对于像我这样的emacs新手具有非常大的帮助,我已经完全按照你的建议来做。
教程需然全部都是英文书写,但是语法简单、文笔流畅,像我这样纯粹的中国人都可以轻松阅读。
From: Will Parsons Date: 3 Sep 2008 00:21:16 GMT Subject: Re: ergonomic keybinding. Need qwerty testers.
Some comments:
I’ve been giving your keyboard mapping a try and generally like it. In particular, I like the cut/paste series (M-x, M-c, M-v) and the window-splitting series (M-0, M-1, M-2). I do regret, however, that the M-c binding does conflict with the default capitalize-word binding, as I use the capitalization functions bound by default to M-c, M-u, and M-l pretty frequently. At the moment, I’ve configured a “windows” key to be Hyper and bound the capitalization functions to H-c, H-u, and H-l, so I’ll see how that works out.
(I’ve noticed a slight anomaly - since M-x is bound to kill-region, M-a is used for execute-extended-command, but when one hits M-a, one is still presented with a prompt “M-x “.)
As far as the cursor movement bindings, the single character movement bindings seem natural enough, but I suspect I’ll prefer to continue to use arrow keys. I’ll have to give the other movement bindings more of trial before making a final judgement, though the combinations involving M+S (Alt+Shift) seem a little awkward to me.
I’ve bound M-g to goto-line for some time now, and am happy with the standard C-k for kill-line, so prefer not to rebind M-g.
Similarly, I’ve bound M-p to ps-print-buffer, and since I don’t use the recenter function too often, am happy to stick with C-l for it.
I found the binding of M-d to delete-backward-char somewhat disconcerting, because even though I’ve bound C-delete to kill-word, I’m still acustomed to having M-d perform the same function in other contexts (⁖, in Bash).
From gnu.emacs.help newsgroup.
Hello,
I’ve just read your rant about Emacs key bindings and other historical “features”.
I simply wanted to thank you for this : now I know I’m not alone thinking about this sort of things. Although I didn’t had your historical knowledge about Emacs, these key bindings and features are what has always turned me away from Emacs, and why I coded my own text editor 14 years ago (Jered, available from http://www.librelogiciel.com/ )
So, again : THANKS A LOT !
bye
Jerome Alet
a few weeks ago I saw your page with ergonomic keybindings for emacs. Since I did not like the original bindings very much and was on the way to an “emacs pinky” I tried your keybindings - they are great ☺
Pain decays slowly and the new bindings are going into muscle memory quickly. Of cource, I made a few changes according to my special needs.
Thank you VERY much!
Markus Grunwald
I have used your ergonomic_keybinding_querty.el a bit. It is interesting, it looks like it is the right way to go. Solution is elegant and does not interfere with or disable common shortcuts. There are two small issues I encountered: The first is that if CUA is enabled in emacs 22 moving around with page up/down (M-Shift-i and M- Shift-k) sets mark and starts selecting a region. The other issue is that on Windows pressing righ-alt + right-shift sometimes changes Windows keyboard layout.
The main issue for me still remains position of Control keys, but this needs to be addressed by a keyboard manufacturer.
Thanks,
boskom
gnu.emacs.help newsgroup, 2008-04-30.
Pretty impressive.
Do you have the frequency of the C-x prefix ? I use it pretty often, just wondering what’s his rating. I definitively want to try your layout. Two remarks though. C-h = delete-backward-char is mandatory for me.
Too many applications use it that way. And the h key is a perfect spot on the Dvorak keyboard.
Also, C-t, M-t and M-c on a Dvorak keyboard definitely deserve better shortcuts than the default ones.
I am currently using C-t as the C-x prefix and M-t as M-x.
Please enable JavaScript to view the comments powered by Disqus. comments powered by DisqusSergio // Sep 12, 2007 at 12:06 pm
That’s nice, but the best thing about that website is the ‘ergonomic keybord layout’ that uses completely new bindings that are way more comfortable.
I know that for long-time emacs users a new layout is perhaps not something attractive, but for me, being new to emacs, a more modern and ergonomic layout is just what I needed to get up to speed.
They even have a Dvorak version. Great resource, thanks, I had been looking for this kind of info about how to make it easier to use emacs for a while.
Here are some ideas for future versions:
- Use Apps/Menu key to have unchorded keys to reduce probability of RSI. See Banish Key Chords.
- Allow ergoemacs-mode keyboard themes to be customized based on user frequency.
If you have any ideas please drop me a line.
This section is experimental ergoemacs keybindings that are being incorporated into ergoemacs. These are likely to change and are a work in progress.
This is an experimental ergoemacs feature to banish key chord and replace ergoemacs keys. The background is given in the following pages
- Why it would be good to banish key chords.
- Xah’s quest to totally redesign the keys.
For emacs, the most common key sequences start with C-x or C-c. This usually requires the use of the control key, and leads to the dreaded emacs pinky. It also conflicts with the standard Cut and Copy commands (see standard shortcuts).
I’ve thought about how to take out the use of the control key and reduce the key chord reduction. This is how I came up with the Ctrl+c and Ctrl+x replacements:
- Ctrl-x commands can be accessed by QWERTY
Menu d
- This is not the same as the traditional Ctrl+x. Heres how its
different:
- By default all Ctrl commands are translated to Alt commands.
- Ctrl+x Ctrl+b could be accessed by Menu d Alt+b (list-buffers)
- C-x b could be accessed by Menu d b (switch-to-buffer)
- Pressing Menu will
change the type of key translation used. The default for Ctrl+x is
translate/swap the Alt and Ctl keys. Pressing Menu again will:
- Make the keyboard translation for C-x “unchorded”
- The pressing Menu would remove the keyboard translation for Ctrl+x.
- Finally pressing Menu again would result the translation/swap of Ctrl and Alt (as at the beginning).
- By default all Ctrl commands are translated to Alt commands.
- This is not the same as the traditional Ctrl+x. Heres how its
different:
For your information, an “unchorded” filter/translation would translate:
- Ctrl key combinations to standard keys. For example Ctrl+b would be just b.
- Standard keys like b would be translated to Alt+b.
- Alt key combinations would be translated to Ctrl key combinations. Therefore Alt+b would be translated to Ctrl+b.
- C-c commands can be accessed by QWERTY
Menu f
- This is not the same as the traditional Ctrl+c. Heres how its
different:
- By default the “unchorded” filter is on. This is because by convention, major modes bind control keys like Ctrl+c Ctrl+r and leave keys like Ctrl+c r to be bound by the user. This means that you would put less strain on your hand to have these key combinations to be unchorded by default.
- Ctrl commands are translated to Alt commands.
- Like C-x, pressing Menu changes the filter
- First Menu press changes the unchorded filter to the ctl <-> alt filter
- Second Menu press removes the filter
- Press Menu again to go back to the unchorded keyboard filter.*
- This is not the same as the traditional Ctrl+c. Heres how its
different:
One can enable movement without key-chords as follows:
- On QWERTY, press [Menu] [k] and then the movement key. This key is
repeatable. Therefore [Menu] [k] [k] [k] would move the cursor down
two lines. If this is followed by [i] this would have the cursor
move up a line. To exit the repeatable movement/delete keys press
[Menu]. This is similar to VIM’s edit mode, with a toggle of the
[Menu] key.
- Shifted keys still are allowed. For example, page up can be accomplished in QWERTY by [Shift+i].
- Any command that enters the minibuffer also exits the repeatable movement/deletion.
- Any undefined key in the keymap (like 1) would exit the mode and insert the character
- To reduce the shifted key-chords, on QWERTY you can also press
[Menu] [i]. Therefore [Menu] [i] [i] is equivalent to one page
up. Followed by a [k] will be the page-down equivalent
- Again, [Menu] stops the movement mode and anything that enters the minibuffer removes the movement mode.
- Any undefined key in the keymap (like 1) would exit the mode and insert the character
- Shift and the key is the unshifted command. Therefore [Menu] [i] [i] [Shift+k] would be Page Up followed by down one character.
You can press [F6] to get all the [Alt+] commands bound letters themselves. For example [Alt+k] is bound to [k]. [Alt+Shift+] keys are bound to [Shift+] or [Alt+] keys. Hence, [Shift+Alt+m] is bound to both [Shift+m] and [Alt+m]. To exit ergoemacs modal mode, you can press [Return] or [F6].
Ergoemacs is a set of customizations that make emacs easier to use. It also includes ergoemacs-mode. The minor mode, ergoemacs-mode, implements the keybindings (and some other features) via a minor-mode that can be toggled to get back to standard emacs.
You can hold the left Alt, then right hand press space to mark, then right hand using any of QWERTY i j k l to move by char, line, or u o to move by word. ⇧ Shift+U and ⇧ Shift+O to move by paragraph/block.
Of course, you can also use the standard shortcuts. For example, to select all, you can press Ctrl+a. To move up, you can press ⇧ Shift+↓ to select text downward.
Another option is to use the ergoemacs reduction key theme. Then the shift-movement keys work.
Ergoemacs-mode allows key sequences to be changed with a backspace key. This masks some of the delete key sequences like C-x Backspace which runs backward-kill-sentence. You can turn this off by the following
(define-key ergoemacs-normal-translation-local-map (kbd "DEL") nil)
If you wish to remove it from the other specialized translations you can do that as well:
(define-key ergoemacs-ctl-to-alt-translation-local-map (kbd "DEL") nil)
(define-key ergoemacs-unchordedl-translation-local-map (kbd "DEL") nil)
You can also allow ergoemacs-mode to translate the Delete key to backspace, so Ctl+x backspace can be typed as Ctrl+x Delete key
Some of ergoemacs keys make use of the 【▤ Menu】 key. One way to set this up in a mac is to replace the Caps Lock key with F13 or above, and tell emacs that F13 is actually the menu key. This is done by:
- Downloading and installing PCKeyboardHack
- Going to the system prefences and PCKeyboardHack
- Change the caps lock mapping to F13
- Adding the translation to emacs startup script (like ~/.emacs or ~/.emacs.d/init.el) as follows:
(define-key key-translation-map (kbd "<f13>") (kbd "<menu>"))
The emacs key notation is common across emacs, but not common for new
users. One of the goals of ergoemacs-mode is to allow new emacs users
to not have to learn anything about the keys to start using emacs.
Therefore, all keys are defined in Ctrl+s notation instead of C-s
notation.
You have some options to get to copy and paste:
- You can Alt + the normal key positions for undo cut copy paste
- If you want, you can easily do it with:
(global-set-key (kbd "<C-j>") 'ergoemacs-cut-line-or-region)
- If you want you can keep all standard shortcuts in the normal QWERTY positions by:
(setq ergoemacs-theme nil)
(setq ergoemacs-change-fixed-layout-to-variable-layout t)
(setq ergoemacs-keyboard-layout "dv")
(require 'ergoemacs-mode)
(ergoemacs-mode 1)
The default for Emacs on the mac maps the Alt key to Meta and Command to Super. Because Ergoemacs-mode uses the Meta key so extensively, you may want to swap this mapping. To swap them, set:
(setq ns-command-modifier 'meta)
(setq ns-alternate-modifier 'super)
Note that this can interfere with some global shortcuts. For example, Ergoemacs-mode uses Meta-SPC to set the mark. However, typing Command-SPC ordinarily brings up Spotlight. To disable this and allow Ergoemacs to use this binding, go into
“` System Preferences -> Keyboard -> Shortcuts -> Spotlight “`
and disable that binding.
If you are a long time emacs user, you may find it painful to adopt this setup.
This difficulty is nothing special. It’s the same difficulty when you switching to dvorak after years of qwerty. Basically, it’s about changing muscle memory.
Here are some key-themes that may help you adopt ergoemacs-mode:
If you find it too painful to switch, don’t use the whole package. Instead, start off with just the arrow key movements.
(setq ergoemacs-theme "lvl1")
(ergoemacs-mode 1)
Either put the above in your emacs init file (usually at ~/.emacs
or
~/.emacs.d/init.el
), or customize ergoemacs-mode to set the theme to
lvl1.
With only the above change, you will increase your emacs productivity, especially if you are a touch typist. These single char cursor moving commands are the top 4 most frequently used emacs commands by statistics, roughly accounting for 43% of commands that have a shortcut.
Once you used the above for a couple of weeks, you may add more keys to adopt.
file:ergoemacs-extras/lvl1/ergoemacs-layout-us.png
Adding keys for moving around words and deleting words.
(setq ergoemacs-theme "lvl2")
(ergoemacs-mode 1)
file:ergoemacs-extras/lvl2/ergoemacs-layout-us.png
Full ergoemacs keyset without the <apps>/<menu> unchorded keys.
(setq ergoemacs-theme nil)
(ergoemacs-theme-option-off '(apps apps-apps apps-punctuation apps-swap))
(ergoemacs-mode 1)
file:ergoemacs-extras/lvl3/ergoemacs-layout-us.png
Try to use the full ergoemacs mode.
(setq ergoemacs-theme nil)
(ergoemacs-mode 1)
file:ergoemacs-extras/ergo-layouts/ergoemacs-layout-us.png
The guru theme takes away the arrow keys and page up/page down keys.
(setq ergoemacs-theme nil)
(ergoemacs-theme-option-on '(guru))
(ergoemacs-mode 1)
The hardcore theme takes away the backspace key as well as the arrow and page up/down keys.
(setq ergoemacs-theme nil)
(ergoemacs-theme-option-on '(guru no-backspace))
(ergoemacs-mode 1)
You can make bash understand ergoemacs-mode keys by creating an
appropriate .inputrc
and placing it in your home-directory.
When ergoemacs-mode is enabled, this can be done easily by typing
Alt+a ergoemacs-bash
This should also be available in the ergoemacs menu.
In windows some of the ergoemacs keys are implemented system wide by assuming apps follow the CUA-style keys like CTRL-f for find, CTRL-h for replace. This also optionally implements:
- CapsLock as Menu in emacs
You may want to customize your ergoemacs-mode bindings to fit your particular workflow. This can be accomplished in many ways,
These keys are defined in the ergoemacs-keymap
. When the layout
changes by changing options, these keys are lost. However, you may
create your own theme to allow these keys to be saved.
Ergonomic keys can be added by:
(ergoemacs-key "M-a" 'execute-extended-command "Execute")
This adds the Alt-a command to all keyboards based on the QWERTY layout. This only applies to the currently selected keyboard theme.
Note the last parameter is optional and allows Ergoemacs to document that this is an “Execute” command when generating keyboard layout diagrams.
Fixed keys can be added by:
(ergoemacs-fixed-key "C-o" 'ido-find-file "Open File")
This adds the fixed key to the currently selected emacs theme
Note the last parameter is optional and allows Ergoemacs to document that this is an “Open” command when generating keyboard layout diagrams.
When you want to add an ergonomic keymap with fixed mappings such as the ergoprog theme you can add them as follows:
(ergoemacs-key "M-m s" 'save-buffer "" t)
This converts the QWERTY M-m keybinding and the fixed keybinding s to save buffer
Ergoemacs respects emacs globally defined keys. To define a global key, you can use:
(global-set-key (kbd "M-a") 'backward-char)
(global-set-key (kbd "C-a") 'backward-char)
This uses emacs key notation. In short M-a
represents Alt+a, C-a
represents Ctl+a. For these two examples the key is bound to emacs function
backward-char
.
When you define a global key that conflicts with ergoemacs-mode keybindings (after loading ergoemacs-mode) the binding will no longer active in ergoemacs-mode. Therefore, the binding should be active in most places in emacs.
There is still a possibility that another major or minor mode will
bind the key. If that occurs, you can locally override the bindings.
Assuming this occurs in silly-mode
, you can usually override the
settings by setting the keys locally in the major-mode:
(add-hook 'silly-mode-hook
(lambda()
(local-set-key (kbd "C-a") 'backward-char)))
Also note that the order that you define the global-keys matter when
using ergoemacs-mode
. For example, if you decide to change the
global binding before ergoemacs-mode
loads, the key definition is
typically ignored when ergoemacs-mode
is enabled. For example:
(global-set-key (kbd "M-a") 'backward-char)
(require 'ergoemacs-mode)
(ergoemacs-mode 1)
The keyboard definition for backward-char
is ignored when
ergoemacs-mode
is enabled. However, if you use:
(require 'ergoemacs-mode)
(global-set-key (kbd "M-a") 'backward-char)
(ergoemacs-mode 1)
then ergoemacs-mode will respect the Alt+a backward character assignment.
This behavior allows ergoemacs keybindings to override the keys in an emacs configuration like prelude, emacs-live, etc. If you do not like this behavior, you can turn it off by:
(global-set-key (kbd "M-a") 'backward-char)
(setq ergoemacs-ignore-prev-global nil) ; Will not ignore any globally
; defined keybinding
(require 'ergoemacs-mode)
(ergoemacs-mode 1)
In this example Alt+a will be bound to backward-char
for
ergoemacs-mode as well as globally.
If you are loading ergoemacs-mode
before loading one of these emacs
settings and you want to ignore the keybindings of the settings,
you can also ignore them by using the following code
(global-set-key (kbd "M-a") 'backward-char)
(require 'ergoemacs-mode)
(ergoemacs-mode 1)
;; Load starter kit here
;; Ignore starter-kit keys in ergoemacs-mode
(ergoemacs-ignore-prev-global) ; Globally defined keys defined
; before this point are ignored
One of the disadvantages of using globally defined keys it they will
be bound globally even if ergoemacs-mode
is not active.
Additionally, they are not Layout independent. For example, defining
Alt+j on QWERTY will not change to Alt+n for colemak.
Emacs commands are very long and descriptive. It may be a good idea to shorten commands you use frequently. This can be done by defining aliases.
Ergoemacs-mode already adds support for a few commonly used commands
like allowing eb
be the same as eval-buffer
. These are defined
in the variable ergoemacs-aliaeses
which may be customized. This
can also be turned off by setting ergoemacs-use-aliases
to nil:
(setq ergoemacs-use-aliases nil)
Often you wish to move to the beginning of some part of a line. For example:
(progn
(ergoemacs-mode 1)) ; This turns ergoemacs-mode on.|
With the cursor |
at the end of the line, you might want to go to
the beginning of the comment:
(progn
(ergoemacs-mode 1)) ; |This turns ergoemacs-mode on.
That way you can delete and change the commment (With QWERTY 【Alt+g】).
You may even want to go to the end of the code line:
(progn
(ergoemacs-mode 1))| ; This turns ergoemacs-mode on.
That way you can delete the comment entirely (With QWERTY 【Alt+g】).
Often you may want to go back to the first non-whitespace character of the line like:
(progn
|(ergoemacs-mode 1)) ; This turns ergoemacs-mode on.
Or even the fist actual first character of the line:
(progn
| (ergoemacs-mode 1)) ; This turns ergoemacs-mode on.
Once there it is not too useful to go to the beginning of the line again. So, you may wish to:
- Goto the last text block (separated by 2 new lines; default, why?)
- Issue a page-up command
- Goto the beginning of the buffer
All of these can be accomplished by the smart ergoemacs-mode
beginning-of-line
function, which is bound to 【Alt+h】.
If you don’t want ergoemacs-mode to ignore comments when going to the beginning or end of the line you can change this behavior by:
(setq ergoemacs-end-of-comment-line nil)
You may want to only go to the beginning of line, instead of the beginning of the indentation (the first non whitespace character). This can be changed by
(setq ergoemacs-back-to-indentation nil)
You can change the command that is issued at the beginning of the line by using one of the following commands.
(setq ergoemacs-beginning-or-end-of-line-and-what 'block) ; Beginning
; of text block
(setq ergoemacs-beginning-or-end-of-line-and-what 'page) ; Page Up
(setq ergoemacs-beginning-or-end-of-line-and-what 'buffer) ; Beginning
; of Buffer
You may worry about smart mode-specific commands such as org-mode’s
beginning or end of line. Don’t worry ergoemacs-mode will respect
it, and do the right thing. This is because ergoemacs-mode actually
replaces the move-beginning-line
with whatever the mode defines
move-beginning-line
to be.
For example set:
(setq org-special-ctrl-a/e t)
And then go to an org-mode
headline:
* TODO Install ergoemacs-mode |
By pressing the beginning of line command, you would go to:
* TODO |Install ergoemacs-mode
As hoped/expected.
The end of line command for ergoemacs is just as smart as beginning
of line. For example if your cursor is |
, and you are at:
(progn
| (ergoemacs-mode 1)) ; This turns ergoemacs-mode on.
may wish to go to the end of the code block:
(progn
(ergoemacs-mode 1))| ; This turns ergoemacs-mode on.
or the end of the line:
(progn
(ergoemacs-mode 1)) ; This turns ergoemacs-mode on.|
The after that you can:
- Goto the next text-block (default, why?)
- Issue a PageDown command
- Goto the end of the buffer.
Currently this command is bound to 【Alt+Shift+h】
You can ignore the comment feature by the following initialization code:
You can change the command that is issued at the end of the line by using one of the following commands.
(setq ergoemacs-beginning-or-end-of-line-and-what 'block) ; End
; of text block
(setq ergoemacs-beginning-or-end-of-line-and-what 'page) ; Page Down
(setq ergoemacs-beginning-or-end-of-line-and-what 'buffer) ; End
; of Buffer
Note that this command also respects mode specific changes to
end-of-line commands (like in org-mode
).
This smart will:
- Goto the beginning of the buffer
- If at the beginning of the buffer it will go to the end of the buffer.
If you want to go to the beginning of the buffer only, you can turn it
of by setting ergoemacs-repeatable-beginning-or-end-of-buffer
to
nil:
(setq ergoemacs-repeatable-beginning-or-end-of-buffer nil)
Ergoemacs can allow a paste command to cycle through the previous items that were copied.
In this case Ctrl+v:
- Pastes the first item
- Upon repeating, Ctrl+v cycles through previous items pasted.
Note that if you move/type then this pattern repeats itself, you will paste and then cycle through the items pasted.
If you wish to paste an item twice, you can use Ctrl+Shift+v.
When this is disabled, the Ctrl+v only pastes and Ctrl+Shift+v cycles through the previous items pasted. This can be disabled by
(setq ergoemacs-smart-paste nil)
This is enabled by default because it reduces pinky usage.
When installed, ergoemacs’ smart paste can also use browse-kill-ring
When calling Ctrl+Shift+v if the last command was not a paste, it starts browsing the kill ring. The standard ergoemacs-mode keys apply. Pressing Ctrl+v or Alt+v will cycle forward through the kill ring. Pressing Ctrl+Shift+v or Ctrl+Alt+v will cycle backward through the kill ring. To accept the text, press enter.
If you want the second paste to call browse-kill-ring
, you can
enable this by:
(setq ergoemacs-smart-paste 'browse-kill-ring)
This command is an extension of the smart Letter-Case command. It also toggles camelCase words when it detects you are in a variable. When you are outside of a word, it corrects the last mis-spelled word.
The camel-case is determined by the major-mode’s mode’s settings in
ergoemacs-toggle-camel-case-chars
. In emacs-lisp it is more common
to separate variables with -
rather than _
. The default setting
for emacs-lisp-mode
allows toggling between the various variables.
For exampleVariable emacs-lisp toggles between the following:
- exampleVariable
- ExampleVariable
- example-variable
- example_variable
In R
it is likely that you separate variables by .
or _
so
exampleVariable would be toggled between
- exampleVariable
- ExampleVariable
- example.variable
- example_variable
In some modes, like org-mode
only the toggle letter case is
active.
Any of these can be customized by customizing the variable
ergoemacs-toggle-camel-case-chars
.