I would like to use "Ctrl+'" to replace "\" (i.e., the backslash key). How should I do that? Originally I did it by kbd macro, but it is still different. For example, for the package smartparens, if one types "\{", a "\}" will be automatically typed. However, keyboard macro "ctrl+'"+"{" is not the same as "\{" for this case.
So I am just wondering if there are other ways achieving this? Some global keybinding tool (works for the whole X system) is also ok. But so far I cannot find one that can do such keybinding (two keys for one key).
Thanks!
Related
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
In Emacs everything is about hotkeys. Everybody who creates new shortcuts knows the problem:
Which hotkeys should be used?
Which hotkeys are used by the most popular Emacs extensions (org-mode...) and should be avoided?
Are there reserved hotkeys for "users" that will never be used by extensions?
Which hotkeys should be avoided, if the code should be public? (Some keys like right/left Win are sometimes missing on keyboards, M-TAB will be catched by the windowmanager)
Is there a list of all reserved hotkeys?
Sticking to the reserved C-c <letter> sequences is as close as you'll get to guaranteeing that you won't conflict with any other code (although it's still just a convention; sometimes you'll see people making code available that uses one of those sequences, but you can report those cases as bugs to the author).
I would suggest using some of the C-c <letter> sequences as prefix bindings for grouping related functionality together. For instance, you might use C-c w <key> as the pattern for window-related functionality. That gives you a dramatically larger number of reserved bindings, probably with better mnemonic properties, and of course the subsequent <key> can be anything at all, not just a letter.
That also lets you use C-c <letter> C-h to list everything you've bound under that prefix, which can be convenient.
The GNU Emacs Lisp Reference manual has a detailed page on key binding conventions:
http://www.gnu.org/software/emacs/manual/html_node/elisp/Key-Binding-Conventions.html
The keys C-c <letter> are reserved for the users, so packages should normally not use them (note that "letter" is really a letter of the alphabet, not "any key" or "any character"). But most users just use which ever key they like and when that binding conflicts with some package, they handle the conflict in an ad-hoc way (either by using another key, or by specifically overriding the package's binding).
automate key-binding checks evaluating forms like
(key-binding [(control c) (delete)])
When coding in elisp, I find that I'm stopping at hyphens when moving by words, and would prefer to ignore them.
What's the simplest way to do this?
M-x modify-syntax-entry RET - RET w RET should do it. Or if you prefer an elisp snippet that you can add into a hook, (modify-syntax-entry ?- "w")
The syntax table for a mode contains information on what constitutes various syntactic classes (e.g. words, spaces etc.). These are used to determine the operation of commands such as forward-word etc. Modifying it change the behaviour of these commands.
Instead of changing Emacs' notion of words, it might be preferably to navigate by s-expressions (C-M-f, C-M-b) to skip whole identifiers. That way, you keep the convenience to be able to navigate by the partial words if you want to change an identifier.
You can use interactive regex search. Pressing just C-M-s SPACE should search for any whitespace (you might need to configure search-whitespace-regexp).
I am fairly new to eclipse as far as it regards programming. After reading docs and faqs the whole day, I learned that key sequences can be bound to commands, which in turn can invoke actions (or was it the other way around?). Anyway, I miss a list of "standard actions", surely, inserting a character in response to a key stroke must be standard? But I din't find it.
In an editor I want to bind key sequences to actions like "insert character x", where x is one of a set of characters not on every keyboard (like §°€µöß´, greek letters, etc.).
How do I do this in eclipse?
Do I really have to write a separate command (and or action?) for every character I need? Moreover, if possible I want it to have configurable, of course. But, first things first.
In conventional editors like UltraEdit or jEdit, I would record a macro and bind a key sequence that invokes that. It's done in 1 minute. In jEdit, such a macro results in one line of bsh code that looks like:
insertText("§");
You can try the Eclipse plugin Practically Macro. It allows you to record macros but also to define it by hand.
To create a short key that inserts "§" in your editor you must do the following steps:
Go into "Preferences/Practically Macro Options/Editor Macro Definitions" and create a new macro. Add the command "Insert String" and type § in the text field. Then give the macro a name and an id, e.g., "testmacro".
Go to "Preferences/General/Keys" and search for your newly created "testmacro". You can now bind an arbitrary key combination to it.
in gedit it's possible to define so-called "snippets" for simpler input.
For example, there is a snippet while. This means: If you type while -> (-> stands for tab key). And gedit automatically converts it to the following (including correct indentation):
while (condition){
}
In vim (in conjunction with latex-suite) I saw the following: If you type (, vim inserts just a (. If you type ( a second time, vim automatically converts it to \left( \right).
I found abbrev-mode but this mode doesn't place the cursor properly (i.e. between parentheses or inside the while loop).
I managed to create custom emacs keybindings/macros that do just the same (without having to press the tab key), so I know it's possible.
However, is there already and package where you can define such "snippets" without much effort? Or are there even any serious reasons not to use such things?
See yasnippet. It provides snippets for most major languages, and it is easy to add new ones or modify the old ones.
Yes, yasnippet is probably the way to go. But make sure you learn the major mode you're using for your editing - when writing in LaTeX, learn auctex. Major modes can contain functionality that makes some snippets pointless, and do the same thing even better. So instead of using a begin/end-snippet in a LaTeX buffer, try C-c C-e in auctex. Etc :)
Don't forget abbrev-mode.