From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alex Kost Newsgroups: gmane.emacs.help Subject: Re: Remapping navigation Keys in EMACS Date: Tue, 11 Apr 2017 22:46:47 +0300 Message-ID: <874lxubuc8.fsf@gmail.com> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1491940051 32010 195.159.176.226 (11 Apr 2017 19:47:31 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 11 Apr 2017 19:47:31 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) Cc: help-gnu-emacs@gnu.org To: Rishabh Jain Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Apr 11 21:47:26 2017 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cy1l5-0008C5-Ie for geh-help-gnu-emacs@m.gmane.org; Tue, 11 Apr 2017 21:47:23 +0200 Original-Received: from localhost ([::1]:40916 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cy1lB-0005aF-2p for geh-help-gnu-emacs@m.gmane.org; Tue, 11 Apr 2017 15:47:29 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34086) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cy1kb-0005a6-Mu for help-gnu-emacs@gnu.org; Tue, 11 Apr 2017 15:46:54 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cy1kY-0001XI-GO for help-gnu-emacs@gnu.org; Tue, 11 Apr 2017 15:46:53 -0400 Original-Received: from mail-lf0-x236.google.com ([2a00:1450:4010:c07::236]:36652) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cy1kY-0001X2-8e for help-gnu-emacs@gnu.org; Tue, 11 Apr 2017 15:46:50 -0400 Original-Received: by mail-lf0-x236.google.com with SMTP id s141so3837700lfe.3 for ; Tue, 11 Apr 2017 12:46:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=kzY+b1OAumiASaUtto1WjITNWS4w4jnQXP8MoHiA+64=; b=CaWiKI3JynAfLM34bidDTJRfYUD/Q8Jo6HxQUd/qxqBy3Ee/XtBOrs2fH0cg+MkG9h lMP1XEtBjAsVYFoNDgBMTpP5tyCvMrtcOi5RcsNN0KvF3VjQTmN3z7We9kfSG2W8USqt uUHGZPmmK+sVjv7yj6/n0Qdwh8sAgdS1Vu/M85LRWmmlSpLEe4oIHgkXVfpadF0jyV2Z yGisUBHPASRR3OI0Xbg7iyIPkcRgARJi7WeeTrcBqwKA+3+zlo/fHMR7MF9IfE1T/ab6 +NUtAxmIcUcBjQh8zZOEef+v4sipvPTVIsI+eOnx4PWSnv+JnjLuWal+ItXX0PUFZVph 5IPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=kzY+b1OAumiASaUtto1WjITNWS4w4jnQXP8MoHiA+64=; b=n8rzu3sqMSFbaS8myCquwE48J7ilcGP0DR3A8pV54kM9Jm3+ganRHv8CHeY2ypP+0Y O1ae/2T+xZ8IEibYNeKnEcjWw3kBPo6mjRXe3Oqp1oPAs7HVvohQFdXCK5QWW3qX6u0o DuaW0LsFkb9YjgWuGbjfNuUIpHnzfkeOFA6eQf2G4bVkhOCi6ZC8x2dUc9ZYTkUvIXRR S6f/Bpk9llVa4aX22w/2JJX01MU9qDdAynqO+C9LmeWHKu6Ffyx5GBILB2jVHY2hFcRw Ri3+mvOp+j9Kx3dUsVgOmMUVATJOqCkIVsYHh0PmJ80cYjmT4klXESFBvUjF+xRJjLRr jRlg== X-Gm-Message-State: AN3rC/4VrBNvjS1aaaw9Ur533gRohsJJg+45jvtAab8BNFXBOSFyIodFP+xHrJud3oqq7Q== X-Received: by 10.25.198.197 with SMTP id w188mr3927809lff.175.1491940007243; Tue, 11 Apr 2017 12:46:47 -0700 (PDT) Original-Received: from leviafan ([217.107.194.138]) by smtp.gmail.com with ESMTPSA id e124sm3617025lfg.8.2017.04.11.12.46.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 11 Apr 2017 12:46:46 -0700 (PDT) In-Reply-To: (Rishabh Jain's message of "Tue, 11 Apr 2017 13:53:50 -0400") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::236 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:112747 Archived-At: Rishabh Jain (2017-04-11 13:53 -0400) wrote: > Hi: > > I'm just starting up with EMACS, and am curious if anyone has mapped > their navigation keys (C-f,b,p,n, etc) to WASD format (like games do for > navigation). If you have, please share your experience as well. > > W - up, A - left, S - down, D - right I remap my navigation (as well as text editing, and many other) keys similarly: E - up, S - left, D - down, F - right (actually, I use ".oeu" keys accordingly since I use Dvorak layout). BTW, I wonder why WASD and not ESDF? ESDF (I mean in "qwerty" layout) is a natural position (especially for touch typing). Ah, nevermind, don't answer, tastes differ :-) > Here's how I want to remap: > > * C - (a,d) -> character wise left and right > * C - (w,s) -> line wise up and down > * M - (a,d) -> word wise left and right > * M - (w,s) -> paragraph wise up and down Hey, I use the same key bindings! (except for the other (dvorak) keys). > * C - M - (a,d) -> (sentence wise left, right) > * C - M - (w,s) -> (move current line up/down) Since most of the times I work with lisp-like languages, I use "C-M-..." keys to navigate by sexps (like moving forward, backward, down, up) and to edit them (kill backward, forward, transpose). Nah, no one cares what I use, sorry for bothering. Other than that I had several hundreds of key bindings (maybe more than a thousand including all the additional packages I use) :-) > My biggest concern is that if this remapping would really impede my > EMACS experience in time - for eg. using packages, etc. Here is my experience: I was using "vanilla" Emacs keys for about a year, then I realized that I can use much more ergonomic keys for basic commands, and I began to rebind keys=E2=80=A6 I spent a lot of time on thi= s but I was very pleased with the result (I've been using my remapped keys for about 4 years). Now, how you can bind your keys. There are several ways and their combinations to do that. I'll mention 3 of them: 1. Rebind global keys (with 'global-set-key') and rebind the according keys in all the keymaps of major and minor mode you use (with 'define-key'). This is a very time-consuming task, since all the external packages follow the default Emacs key convention (e.g., n/p/f/b keys for next / previous / forward / backward), and adjusting their keymaps is a permanent process. This is a "die hard" way and I don't recommend it unless you are going to live in Emacs and you are obsessed on configuring every little thing. I mention this way just because I use it :-) 2. Probably the easiest way to remap several keys is to make a minor mode. There is a page about it: . BTW Emacs wiki contains a lot of info about key bindings: (I've never read it though). Returning to that esdf-mode, I don't like how it is written, I would do it like this: --8<---------------cut here---------------start------------->8--- (defvar my-keys-mode-map (let ((map (make-sparse-keymap))) (define-key map (kbd "C-a") 'backward-char) (define-key map (kbd "C-d") 'forward-char) (define-key map (kbd "C-w") 'previous-line) (define-key map (kbd "C-s") 'next-line) map)) (define-minor-mode my-keys-mode "Minor mode with the keys I use." :global t :init-value t :keymap my-keys-mode-map) --8<---------------cut here---------------end--------------->8--- If you add the above code to your emacs config file, you'll get the key bindings (some of them) you want. You can always disable/enable this mode with "M-x my-keys-mode". 3. Finally, there is "ergoemacs" package: . I've never tried it, but maybe it's what you want. Oh well, I can write about key bindings much more, but I should stop :-) --=20 Alex