When using Emacs do you rebind caps-lock to CTRL? [closed] - emacs

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 12 years ago.
Improve this question
This question is, as indicated, for those who use Emacs.
When you do, do you rebind the caps-lock key to CTRL, or do you use the "normal" ctrl key?
I've recently learned some Emacs commands and was using the Visual Studio 2008 emacs commands for a while, and of course I used a caps-rebind tool, but I'm curious how many other people do.
On a side note, the emacs bindings for VS are severely incomplete :(

I have no use for Caps Lock under any circumstances, whether I'm using Emacs or any other program. In the rare case that I need to type several capital letters at once, I can easily hold down Shift with my left pinkie and type almost as fast as normal with my remaining fingers. If I ever needed to produce a large amount of all-caps text using Emacs, I'd just type it all in lower case, select it, and upcase it all at once with C-x C-u, aka upcase-region.
So yes, I do make Caps Lock an additional Control key. I don't just swap them, I eliminate Caps Lock entirely.

I'm not an emacs user, but I use Unix heavily with programs such as screen (and, cough, vim) which use control a lot, and I bind my caps lock to control. Caps lock is a useless key that should have never made the typewriter->computer transition.

Yes I do remap CAPSLOCK to control.

I kept one of my old Sun keyboards with control where God intended it until it would not work with the new UltraSparcs. Ever since I have always remapped them, even if it did result in some odd blinking light behavior on some machines.

Absolutely yes, and I'm really happy with it. Caps Lock is simply unuseful and irritating, switching it to a Ctrl will:
Save you from awkward positions
Save you from accidentally activating Caps Lock

I also have useless MSWindows on my keyboard, so now I have three Ctrl keys on the left-hand side: Caps Lock, Ctrl, and LWin.
RWin generates "menu", which runs execute-extended-command (just like M-x). I'd never even tried pressing it until last week, so I don't know how long that's been the case for, but I'm trying to get accustomed to it.
I'm also trying to get used to using the right-hand Ctrl key when the keys to be modified are on the left side of the keyboard, and not in immediate range of (one of) the left Ctrl keys.

I do, both on windows and linux.

A show of hands? I have been using Emacs on and off over the past 5 years or more. Never bothered about the caps lock key. I do not bind it to control key. C-x C-u did the work every time. I can't recall any instance of having hit the caps lock when i was reaching out to 'a' or tab or 'shift'.
My be it it time for me to change the key binding. I get pain in the hands while typing. I'm going to try and see if having caps lock as control helps.

I found that using 'alt' as 'ctrl' and 'win' as 'alt' is better than the well known 'capslock' method.
Google 'lisp keyboard' you'll get a better idea what I'm suggesting and why Emacs has so many 'ctrl' combinations in the first place -- at the time it's invented the keyboard layouts doesn't look like what it is today.
After failed multiple times trying to use 'capslock' as 'ctrl', now I love the 'alt' way.

Related

Why doesn't emacs detect C-<backspace> combination?

My problem is that I want to bind Control + Backspace combination to backward-delete-word function. However, it doesn't seem possible because emacs doesn't detect the Control key in combination with backspace.
I detected that by looking at the "logger" (C-h l). So if I press Backspace, it shows DEL. If I press Control + Backspace, it still shows DEL.
Is there any way to achieve that?
I have read and tried other questions, but couldn't fix it.
As #phils pointed out, if you are using Emacs in a terminal (e.g. emacs -nw) instead of as a GUI (no -nw command-line option), and if you are not on MS Windows, then by default certain key sequences are not available to you.
However, it might still be possible for you to configure the terminal (e.g., xterm) so that it in fact supports some such key sequences for Emacs. See this comment by the Emacs maintainer in the discussion of Emacs bug #10387.
(That said, you might find it simpler to just use a different key sequence. Or switch to the GUI version of Emacs.)

emacs forward and back keys [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
Am i unusual or are the emacs forward and back keys the wrong way round?
I constantly hit C-b for forward and C-f for backward because b is forward of f and f is back of b as laid out on the (qwerty) keyboard (at least thats my logic)
C-n and C-p cause no such problems as they are intuitively the right way round, e.g. p is 'up' from n
likewise with C-a and C-e
its nice to have the letter mean something, e.g. f for forward and b for back but my brain prefers actual position over the right initial
does anyone else have this issue?
as an aside how do dvorak users cope?
should i swap the key bindings round or does that way madness lie?
(possibly part of the problem is I have only just started weaning myself of the arrow keys using no-easy-keys.el)
If you are willing to move away from the defaults, you may want to check out Xah Lee's ErgoEmacs bindings.
http://ergoemacs.org/emacs/ergonomic_emacs_keybinding.html
Let me answer quickly before the famed SO content nazis delet your question as too open-ended. Emacs keybinding on standard 104 key PC keyboard is a disaster. I personally never confused C-f and C-b, but I did get strained pinkies from pressing Ctrl all the time until I redefined Caps Lock as Ctrl. Since then, by miracle, Emacs became the most comfortable piece of software on my machine. But back to your original question, I think I never had problems confusing C-b because it's simply hard to reach. Nevertheless, as much as I love Emacs, I must admit that vi rocks for using h, j, k, l keys for, respectively, back, down, up, and forward. I've heard there was a plugin named 'vile' for Emacs, but I never tried it. That might be of help to you.

Best keyboards for emacs? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
For emacs users out there, what are your recommended keyboards?
Bonus points for keyboards that:
Have no capslock key. Instead, a control key in that position.
Alt keys that are closer to the centre, and easier to use with meta key combos. I find alt keys too far to the left to be a bit awkward to hit with my thumb in some key combos.
Help ergonomically with emacs in other ways.
I'm not a huge fan of model M style high and clacky keys. I instead prefer laptop style flat keys; however, I'm not disqualifying either category.
A couple of interesting keyboards I'm curious if people have tried with emacs - Kinesis
Semi-conclusion:
I ended up getting an MS natural 4k, which I like a lot overall as the alt keys on both sides are easy to hit with your thumbs. This is useful for ergoemacs-mode.
However, one flaw I see with this keyboard is that the number keys are shifted to the left, so that 6 is on the wrong side of the keyboard. Aside from that 0 is left shifted enough that I accidentally hit - when I meant to hit 0 with my pinky.
Due to this flaw, I'm leaving this question open in case someone can come up with the perfect emacs keyboard.
Richard Stallman (which I'm sure you all know is the author of Emacs, and probably the biggest Emacs user) was seen using a HHKB (Happy Hacking Keyboard) (source)
Here's the layout of the HHKB Pro:
No Caps Lock.
Control key conveniently placed for Emacs users.
They're quite pricey though...
I used the Kinesis keyboard with Emacs for many years and loved it. Having Alt, Ctrl, Del, and Backspace all easily reachable with the thumbs is very, very nice. The location of the arrow keys is also quite convenient.
I have a model M "Das Keyboard" Ultimate - no letters on it, highly ergonomical and very beneficial to my productivity. I used to share your taste for low profile laptop style keyboards, but ever since I got the Das Keyboard I cannot imagine using another keyboard. It's as noisy and heavy as they get, but it's benefits cannot be described by mere words - one has to type on it for himself... Since you can easily remap CAPS to control(which I've done) I don't think that you should consider something like this in a keyboard a particular advantage. Also - if you get attached to using a keyboard with a highly customized key layout you'll be very impaired when you have to do some work from time to time on a regular keyboard...
I use MS Natural 4K, with some keybindings altered to cope with the different geometry.
In particular, I swapped c-p/n with a-p/n.
My hand and keyboard geometry are such that Alt lies directly under my thumb and I can trivially scroll up and down with thumb of left and and first/third finger of the right hand.
I do not have pinky pain.
Also, I use emacs & MS 4K both at work and at home, and I am pretty much 100% happy with it and plan to continue it.
I recently got a ThinkPad USB TrackPoint Keyboard at work, and is very pleased with it.
I always remap the Caps Lock to act as an extrac Ctrl. When I do need the mouse, the trackpoint is right there, no need to move your hand away from the keyboard.
The keyboard is very flat and I like the feel of the keys. I have a couple of thinkpad laptops as well, and as this is essentially the same keyboard, the feel is the same whether I at my desk or working directly on the laptop - that's a big plus.
Here's some photos: http://www.thinkpads.com/2009/08/31/finally-photos-of-new-thinkpad-usb-trackpoint-keyboard/
There is another keyboard on the way designed for use within emacs, its name is the key64 and is a keyboard i am designing from about two years ago, right now i am finishing building the firmware while all the instructions to make the pcb and the parts needed to make the keyboard are available at its website www.key64.org
It's 100% programmable within Linux with gcc-avr as it use a teensy board.
Hope to finish the firmware by the end of January 2013 and publish it at the website for anyone interested in making his own keyboard :)
as an avid emacs user and long time rsi sufferer, the best solution i found was kinesis combined with footpedals. i program the pedals for Ctrl, Alt, Meta, and thus can use the notorious emacs combos with only a single finger. especially repeated Ctrl sequences work very well in this configuration. obviously you'll need to reprogram the keyboard a little bit, but those changes will be obvious.
I have been using Emacs since 1976, and have had a Kinesis classic for about 8 years now. I used to use it with foot switches for Control and Alt, but have found that it is equally effective to simply swap Backspace with Control, and Delete with Alt. I also swap the left side arrow keys with [ and ] to make it easier to type "[", "{", "}", and "]".
To further ease typing, I have created bindings for common programming language sequences that require shifted symbols. For example, in C++ I map "." to a function that replaces ".." with "->". I have also experimented with word abbrevs that are effective only when preceded by a semicolon, e.g. replacing ";pp" with "++".
I use the Kinesis keyboard most of the time; I've had mine for 10 years and recently retrofitted it with the new Linear Feel "Cherry Reds" and it should be good to go for another 10. But the keyboard is perhaps less important than the keymapping. The basic rule is: don't move your wrists when you're typing, at least not more than you have to.
In order to accommodate this on the Kinesis, I have the bottom row mapped to Hyper, Super, Control, Meta. I have Mode_switch on the thumb keys. So I absolutely never have to move my wrists to type key combos. (I use Mode_switch to connect to an "embedded arrow key" layer.)
You can do something similar on any keyboard, for example, your laptop keyboard -- remap the number row to modifiers, using xmodmap. You can still type Shift+num to get the standard symbols. Here is a minimal xmodmap starter kit. Use xev to customize further.
clear Shift
clear Lock
clear Control
clear Mod1
clear Mod2
clear Mod3
clear Mod4
clear Mod5
keycode 9 = s S Left
keycode 10 = d D Down
keycode 11 = f F Right
keycode 21 = w W BackSpace
keycode 22 = e E Up
keycode 23 = r R Delete
keycode 26 = Super_L exclam
keycode 27 = Hyper_L at
keycode 28 = Control_L numbersign sterling
keycode 29 = Meta_L dollar
keycode 30 = F6 asciicircum
keycode 31 = Mode_switch percent
keycode 32 = bracketright braceright
keycode 33 = Control_L parenleft
keycode 34 = Mode_switch ampersand
keycode 35 = bracketleft braceleft
keycode 36 = Meta_L asterisk
keycode 37 = Hyper_L parenright
add Shift = Shift_L Shift_R
add Control = Control_L Control_R
add Mod1 = Meta_L Meta_R
add Mod2 = Hyper_L Hyper_R
add Mod3 = Super_L Super_R
add Mod4 = Mode_switch
add Mod5 = Alt_L
I use a GoldTouch keyboard at work and home, and it works great to keep my arthritis at bay. I've remapped the Caps Lock to the Ctrl-key which helps quite a bit w/emacs-pinky. The Alt-key is a bit problematic, but I've solved some of this with a simple mapping in my .emacs file:
; Replace M-x with C-x C-m or C-x C-c
(global-set-key "\C-x\C-m" 'execute-extended-command)
(global-set-key "\C-xm" 'execute-extended-command)
Any OS allows you, one way or another, to remap all your keys.
This will improve greatly your speed, as long as you are not one of those who actually have to look at the keyboard while they type.
If you do that, you can then choose the keyboard focusing exclusively on the one which has the best physical keys (just try them).
I use Apple's wide keyboard and it's - for me - the best one I've ever used by far.
I like the Sun Type 6 Keyboard for Emacs - http://www.aquaphoenix.com/graphics/SunKeyboardType6/SunKeyboardType6_front_top-large.jpg
Upvoting MS Natural Pro 4000. It is the only Microsoft product I use on a regular basis and can strongly vouch for it.
I use a traditional keyboard, except that I change Caps Lock key to Ctrl and Document key to Caps Lock.
The Comfort Keyboard Original allows remapping of any keys, including Caps Lock -> Control, and is generally very ergonomic.
Is there anyone using these two keyboards?
http://www.trulyergonomic.com/store/products (trulyergonomic; about 250usd)
http://www.personal-media.co.jp/utronkb/ (utron; over 500usd)
Tooooooooo avoid RSI.

How to remap keys when in Emacs?

I am looking for a way to have my control key and caps-lock key switched when I am in the emacs window, but when I go to any other program such as Firefox I want to be able to use the normal control button for new windows, tabs and such.
Additional Information: I am using Ubuntu, but answers for all systems are good since someone else may want to know how to do it on their system.
Emacs never actually sees the CapsLock keycode (under X anyway), so you can't remap the key in Lisp. Take a look at this page for details:
http://www.emacswiki.org/emacs/MovingTheCtrlKey
On windows using Auto Hot Key you can achieve this with this piece of code put in default script:
#IfWinActive, emacs#
CapsLock::Control
#IfWinActive
Auto Hot Key is a very handy utility and it is also free software like in GPL.
For globally remapping keys there is xmodmap. xkeycaps is an interactive tool. You can put control on both keys.
Since you want to remap the keys only for Emacs (which I find somewhat ill-advised) you need to look inside Emacs for a solution. It should be possible, because you can rebind all keys, but it may be too tedious to swap all keys around if the modifiers cannot be swapped.
Personally I map CapsLock to Compose, to type all kinds of funny characters like ä, ß, å, þ, «, —, ...

What to teach a beginner in Emacs? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
If you had a 10 minute hands-on session to teach someone Emacs, what would you show them?
Start emacs: emacs
...
Quit emacs: C-x C-c
What else would you have them do between starting and quitting Emacs, while you stood behind them?
If I had only 10 minutes, I would not teach them any shortcuts at all. All the common shortcuts are available next to the corresponding commands in the menus; those the users can discover for themselves.
The most important things to teach are those that will enable the users to discover/learn by themselves:
That one can quit Emacs with C-x C-c, or File->Quit. When stuck, one should type C-g, and, if that doesn't work, ESC ESC ESC. [This is probably the single most useful advice to prevent total frustration with Emacs, trust me.]
The tutorial: Help->Emacs Tutorial, or C-h t. [This is not a terribly useful shortcut to remember; given how few times one reads the tutorial over the course of one's life...]
The concept that every keystroke in Emacs is bound to a function, and all that Emacs does is execute functions one after another. That there are more functions than can possibly be bound to keys, and functions without a keystroke can be invoked with M-x function-name.
That one can discover what function a particular key invokes with C-h k [keystroke]. Make the user walk through a few of those (including the amusing fact that typing a letter is not special and just invokes self-insert-command, so if one wanted, one could bind the letter 'z' to send email instead :D)
That one can search for possibly useful functions with C-h a (or M-x apropos-command), e.g. C-h a paragraph shows all the commands to do with paragraphs, including what shortcuts will take one to the end/beginning of a paragraph. And that C-h w command-name will tell you if the command is bound to some keystroke or not. [Make them walk through this to discover what the key for undo is -- usually they'll try C-z and it does something annoying :)]
That you can read detailed documentation about what a function does with M-x describe-function (C-h f). That Emacs has great documentation about most things; and M-x apropos-documentation (C-h d) is a great way of discovering stuff.
That one's settings are stored in .emacs, and that one can glean some things by looking at that file even if one don't understand Emacs Lisp.
That one can usually find all keystrokes that "complete" a particular set of keys by typing C-h after it, e.g. 'C-x C-h' will show all the shortcuts starting with C-x; C-h C-h is particularly useful; C-c C-h is useful for mode-specific commands such as when in java-mode or c++-mode or LaTeX-mode, etc. (Hmm, "modes"...)
That when stuck, one can search on http://www.emacswiki.org/. (Or ask a question in the #emacs IRC channel on Freenode, or post to gnu.emacs.help.)
This should fit in 10 minutes, and it's the most important stuff, I think. I wouldn't overload with too many shortcuts to remember; that's pointless anyway -- if the users know how to discover shortcuts, they'll find out shortcuts for whatever they use most frequently. Do have them write down the names of these commands, though, and also about Emacswiki etc.
The important thing is to show them how powerful Emacs is and how universal its model is (all those jokes about it being an operating system are not just jokes). If you just show a bunch of arcane shortcuts to do things they can already do in other editors, Emacs won't seem worth all the trouble. In the same spirit, I also wholly support Anton Nazarov's answer of showing them what Emacs can do (AucTeX if they use LaTeX, etc.) for their specific purposes. Then they can judge for themselves whether Emacs is worth learning, and learn using all the above.
Show them how to start the tutorial: C-h t
C-x M-c M-butterfly
I'd show the most important for that novice user mode.
For example, when I show Emacs to my friends at the faculty of physics, I show them AucTeX with preview-latex and RefTeX. Also iMaxima is great.
If I have to show Emacs to software developers I show them something like JDEE or Python mode with Ropemacs.
Tetris, tramp and w3m can be used to give the idea that Emacs can do everything :)
Then I'd show how to start the tutorial and give link to EmacsWiki.org
i think you show him how
to open and save files
to kill/switch buffers
to switch/kill/split windows
to select a range.
And tell him about M-x . Tell him he write those steps down somewhere. I think basic navigation can be done using arrow keys. Now this is all he needs.
If he knows about M-x , he can easily find search, replace and other stuff.
When giving emacs examples it's never enough to only give the key binding since that can and does vary. C-x M-c is undefined on my system.
When I start XEmacas, until I press a key it alternates between two screens. One of them has the following:
XEmacs 21.4 (patch 21) "Educational Television" (cygwin, Mule) of Tue Dec 4 2007 on vzell-de
`C-' means the control key,`M-' means the meta key
Information, on-line help:
XEmacs comes with plenty of documentation...
M-? F: read the XEmacs FAQ (a capital F!)
M-? t: read the XEmacs tutorial (also available through the Help menu)
f1: get help on using XEmacs (also available through the Help menu)
M-? i: read the on-line documentation
M-x describe-project: read about the GNU project
M-x about-xemacs: see who's developing XEmacs
I would ask that someone to read it out aloud, make sure they understand what it says and then give them, to use in case of emergency, my cell-phone number and a first-aid kit.
I would show the shortcuts for the most common operations such as:
Save: ctrl-x-s
Save as: ctrl-x-w
Open/find file: Ctrl-f
Undo: ctrl-_
Kill buffer: ctrl-x-k
Switch to buffer: ctrl-b
Fill paragraph: M-q
And copy/cut and paste:
Set marker: ctrl-space
Cut: ctrl-w
Copy: M-w
Cut line: ctrl-k
Paste: ctrl-y
Open a file,
Save a file,
Basic navigation,
Set mark, copy, cut and paste,
Show undo and kill ring,
Show C-g,
Show search and replace,
Split window and move to other window,
Switch to other buffers,
Show Tutorial,
Explain Info,
Show dired to:
open some file,
run a command to compress another file,
open, edit and save the compressed file,
open a directory on a remote host,
open & save some file on the remote host,
copy some file from the remote host.
Open a shell and run some long output command and navigate in the buffer.
Learn to use help C-h C-h
Do the tutorial exercice.
Kill something, and another thing, and a third one, then C-y to yank it, and M-y to cycle the kill ring. Big "Woah" factor, quick and cheap. Then tell them it works in their daily shell.
Navigate in the buffer with the mark ring. C-u C-SPC (space) takes you to where you were before and, repeated, cycles though the 16 last positions, regardless of edit state.
You know when you sheepishly undo things just to get "where you were before" ? There you go.
This is a killer emacs ninja trick. Everybody should know it ASAP.
I think the first thing to ask before trying to teach them something is "what do they want to get out of learning Emacs?" AND, are you trying to sell them on the idea of learning Emacs or are they already committed.
If they are a programmer and are looking for a new development environment, show them ECB, how tags work, etc? If they are looking for a general text editor, show them M-x re-builder. If they are looking to write documents quickly and publish them eventually, show them org-mode with HTML and LaTeX exports.
Besides what had been mentioned already I would also show them M-x global-set-key after having showed M-x in general and M-x apropos.
I would tell them that the point of Emacs is that it is infinitely customizable and that one should personalize it to suit one's preferences. I would tell them to try out the standard key bindings first and the advantages of them showing up in Bash, OS X, etc.
C-g
Copy paste
Split Windows
M-x
Apropos
Describe Key
Describe Command
Open files
Switch Buffers
The language-specific development environment, including the debugger and the REPL.