* Re: Remapping navigation Keys in EMACS
2017-04-11 17:53 Remapping navigation Keys in EMACS Rishabh Jain
@ 2017-04-11 19:46 ` Alex Kost
2017-04-11 20:07 ` Stefan Huchler
1 sibling, 0 replies; 4+ messages in thread
From: Alex Kost @ 2017-04-11 19:46 UTC (permalink / raw)
To: Rishabh Jain; +Cc: help-gnu-emacs
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… I spent a lot of time on this 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: <https://www.emacswiki.org/emacs/esdf-mode>.
BTW Emacs wiki contains a lot of info about key bindings:
<https://www.emacswiki.org/emacs/CategoryKeys> (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: <http://ergoemacs.github.io/>.
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 :-)
--
Alex
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Remapping navigation Keys in EMACS
2017-04-11 17:53 Remapping navigation Keys in EMACS Rishabh Jain
2017-04-11 19:46 ` Alex Kost
@ 2017-04-11 20:07 ` Stefan Huchler
2017-04-12 12:11 ` Rishabh Jain
1 sibling, 1 reply; 4+ messages in thread
From: Stefan Huchler @ 2017-04-11 20:07 UTC (permalink / raw)
To: help-gnu-emacs
Hi,
keychords are no real good idea, I use a modal mode (xah-fly-keys) and
there a jkli binding is active. (I even bound other stuff on the arrow
keys :) ).
But you dont have to use Ctrl for it. Also ergoemacs mode is a worth
looking there also this jkli is there. word wise you use u and o and so
on.
Hope that helps you.
p.s.
I think using right hand keys for that makes sense, cause you probably
dont use mouse and arrow keys at the same time. either you scroll with
the mouse or the keys but not both. so if you use the mouse for lets say
scrolling, you have other commands on the left hand at the same time.
Rishabh Jain <rjain.ece@gmail.com> writes:
> 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
>
> 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
> * C - M - (a,d) -> (sentence wise left, right)
> * C - M - (w,s) -> (move current line up/down)
>
> My biggest concern is that if this remapping would really impede my
> EMACS experience in time - for eg. using packages, etc. At this time,
> I'm about 1 week old user, and primarily code in Python, and Matlab,
> and work regularly in Latex. For the last reason, I'm really looking
> forward to using org-mode.
>
> Thanks again for taking the time,
>
> Regards,
>
> RJ
^ permalink raw reply [flat|nested] 4+ messages in thread