It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I do not know if this bothers you too or no. Emacs for some reason uses these key combinations. Some of them are crazy. You want to undo something, guess what! ctrl+shift+dash ! 3 keys at the same time, and sometimes they are not pressed quite simultaneously and you have to repeat it. And during this long process you keep typing some unwanted characters on the screen and have to delete them latter on etc .... or ctrl+shift+< . Undo in vim is just "u" !
I am getting tired of these combinations. But I like other features of emacs and do not want to move to vim. How do you guys deal with this problem? have you mapped the keys, or got used to emacs chord keys?
Remapping emacs native keys I guess is not a good idea for various reasons. Not sure how many people actually do it.
I've used emacs for a very long time, and except for a very few exceptions, I just learn the keybindings. It's mostly a matter of practice. On Windows, you might want to consider making CapsLock an extra Control key, which helps some of the finger gymnastics substantially. I recommend against completely redefining the standard keybindings, but if there's something you positively just hate, of course no problem to redefine it to your liking. Emacs reserves a few prefix keys (C-c for sure, and maybe some others that I can't recall right now) for user-defined key sequences.
Note also that there are sometimes alternate keybindings already defined. With respect to undo, it is also bound to any C-/ and C-x u. I personally use the latter. You can find this out with C-h k C-_. C-h k is the binding for describe-key, which tells you what any particular key sequence you type in does, and what other keys, if any, it's on.
If you're just starting out with emacs, reading the tutorial (C-h t) can be somewhat useful.
You may define your own key combinations in a .emacs file. It uses lisp language, if you don't understand it, just copy/paste existing lines.
Read this page for examples: Link
EDIT
To bind undo with Ctrl+z:
(global-set-key (kbd "C-z") 'undo)
And other useful lines:
(global-set-key [home] 'beginning-of-line)
(global-set-key [end] 'end-of-line)
I like this one too, which copy/cut/paste with Ctrl+Ins/Shift-Suppr/Shift-Ins:
(pc-selection-mode)
I most certainly rebind keys. Indeed, I think many of the default keybindings are quite useless and annoying, so when I can get it, I map 'undo' to the "undo" function key, otherwise to a short combo like Ctrl-- or something. Sinsedrix has already shown how to do persistent key rebinding.
(And don't worry too much about using nonstandard bindings. True, if someone else has to type into your editor it may slightly complicate things, but that isn't really very often. It is no way comparable to defining your own keyboard layout, like Dvorak in a QWERTY environment, which is what people usually warn against.)
Related
I want to set up a sort of ISearch mode replacement in Emacs, where I can run a command after every input to the minibuffer. Is it possible?
EDIT 1:
The idea is to completely replace ISearch with my own mode. Ideally, I'd like it to have most of the functionality that ISearch has (like highlighting results as you type). To implement some, I'd need to run a command after every key is input. Is there a way to trigger a function when the minibuffer change, or should I use something that isn't the minibuffer?
EDIT 2:
To be more specific, basically I am looking to take a string from the minibuffer and highlight all matches in the buffer, much like in ISearch mode. So essentially, after each letter, symbol, or number inputted into the minibuffer, I'd like to be able to recognize that change and run some arbitrary elisp. Similar to how helm recognizes input and updates search results.
You wan to use minibuffer-with-setup-hook and in the setup hook, you'll want to either use post-command-hook or after-change-functions.
E.g.
(defun my-update-function (beg end len)
(let ((str (minibuffer-contents)))
<update-search-result>))
..(minibuffer-with-setup-hook
(lambda ()
(add-hook 'after-change-functions #'my-update-function))
...(read-string ...) ...)
See variable minibuffer-exit-hook.
In general, for this kind of question, look for a variable whose name ends in hook (or function or functions). Use commands such as apropos to find a variable (or function) whose name contains various substrings (e.g. -hook, minibuf).
Your question is, however, a bit unclear. Will you actually be using Isearch, or are you going to replace Isearch with something that uses the minibuffer? Please specify more precisely what you are doing.
FYI - Isearch does not use the minibuffer (except when you use M-e to edit the search string).
Update after your Edit 1:
Now I'm afraid your question is too broad, and risks being closed for that reason. You are essentially vaguely asking how to implement some kind of a replacement for Isearch.
If you want to do something after each command, see post-command-hook. But beware that nearly every key press is a command invocation.
Update after your Edit 2:
In that case, consider looking at what other libraries do in this regard. For example, highlight.el (e.g. hlt-highlight-symbol), highlight-symbol.el, color-moccur.el, Icicles (e.g. icicle-occur), and Helm (e.g. helm-swoop). Some of those, such as Icicles and Helm, provide incremental highlighting update as you describe. Others highlight a given name that is entered in the minibuffer (i.e., using RET, not just characters typed in the minibuffer).
But you might want to specify what you want that is different from what such libraries already do. Your question still seems overly broad, to me.
In general, things such as Isearch that do incremental updating read key presses and respond accordingly. They may do this from the minibuffer or at top level, but the point is that they generally do not require a user to enter something in the minibuffer, using RET. They respond after each key press (or each command invocation, e.g. via post-command-hook).
Given that there are so many major modes which define their own maps for this prefix (e.g. latex, org, term), is there a safe way to move these maps somewhere else, and always have the C-c key free?
I'm hoping there's a convenient way, because I noticed ErgoEmacs does exactly this.
As far as i know, there no easy way, unless you dive deep into emacs innards and create ways to remap every mode's keys on load. (I think Matthew Fidler is actually working on this)
ergoemacs-mode does not remap the C-c. It turns on cua-mode, but cua-mode doesn't remap C-c neither, it just create several clever ways so that key can be used for multiple purposes (e.g. by the speed you press the key, or whether there's a text selection, etc.). All C-c * keys are still there.
see discussion on this same question here
https://plus.google.com/103652929131043355278/posts/Nb4xn4gDB6p
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.
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.
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.