I am trying to learn Emacs after about a year of using Eclipse 3.2/3.3. See this post for some reasons why. Below is a list of Eclipse keyboard shortcuts and their Emacs equivalents. I'm using Emacs 22.1 for Windows.
Update 2009-07-20: After almost 2 years, I am still happily using Emacs (now Emacs 23 on Ubuntu). I made a few small corrections/updates to the table below.
|ECLIPSE COMMAND||SIMILAR EMACS COMMAND|
(Emacs manuals use C for the CTRL key and M for the Meta or Alt key. So, e.g. C-x means CTRL+X. For Emacs long commands, you can type TAB to complete the command name.)
|Cancel a command|
|Cancel a command|
Keybinding: C-x C-f
Command: M-x find-file
Notes: Type in the file to open. Hit TAB for filename completion. Hit up and down arrows for recently used files.
Keybinding: C-x C-s
Command: M-x save-buffer
|Save As||Write file|
Keybinding: C-x C-w
Command: M-x write-file
Unlike Eclipse, Emacs' buffers and windows are distinct so closing a buffer and closing a window require separate commands.Kill this buffer
Keybinding: C-x k
Command: M-x kill-this-buffer
Keybinding: C-x 0
Command: M-x delete-window
CTRL+Z / CTRL+Y
|Undo/ Undo Undo|
Keybinding: C-_, C-x u, C-/
Command: M-x undo
To redo, interrupt the undo sequence by entering any command (e.g. C-f), then undo again. This undoes what you just undid, which is like redo. See 21.1 Undo in the GNU Emacs Manual.
This behavior can be confusing so there is also a RedoMode which behaves more like Eclipse and other editors. See RedoMode on the Emacs Wiki.
Keybinding: CTRL+F6 or CTRL+SHIFT+F6
Command: CTRL+3 Next Editor or CTRL+3 Previous Editor
Keybinding: C-x RIGHTARROW or C-x LEFTARROW
See also: 24 Using Multiple Buffers in the Emacs Manual
Keybinding: CTRL+F7 or CTRL+SHIFT+F7
Command: CTRL+3 Next View or CTRL+3 Previous View
|After splitting into 2 windows with C-x 2, use C-x o to switch between windows.|
To scroll the other window, use C-M-v. This is useful to reference one window while editing in the other.
To close the other window, type C-x 1 in the window you want to keep.
|Find and Replace|
Command: M-x replace-string RET string RET newstring RET
Command: M-x replace-regexp RET regexp RET newstring RET
See also: 20.9 Replacement Commands
|Show line numbers|
Command: CTRL+3 Show Line Numbers
|Linum (Emacs >= 23 only)|
Command: M-x linum-mode
For Emacs <= 22, look in your status bar for the line number or see http://www.emacswiki.org/cgi-bin/wiki/LineNumbers
|Dynamic Abbrev Expansion|
Command: M-x dabbrev-expand
This command is much faster and simpler than Eclipse because it doesn't use the compiler/interpreter. However, I think it is less robust for the same reason. At this point, I think I like the Eclipse version better.
See also 34.6 Dynamic Abbrev Expansion in the manual.
Command: CTRL+3 Keys - General
Keybinding: C-h b
Command: M-x describe-bindings
|Comment DWIM (Do What I Mean)|
Command: M-x comment-dwim
|Shift Right (or Left)|
Keybinding: TAB (SHIFT+BACKSPACE)
|Shift Region Right (or Left)|
Keybinding: C-c > (C-c <)
Note: This doesn't work if you're in CUA mode (i.e. using C-x/C-c/C-v Cut and Paste)
|Find text in Workspace|
Command: Find Text in Workspace
|grep (and variants)|
Command: M-x lgrep RET string RET filepattern RET directory RET.
See also 32.4 Searching with Grep under Emacs
I still miss this one in Eclipse. grep has more power than Eclipse, but the combination of pretty highlighting and searching across files is nice in Eclipse. I have created an Elisp function to at least grep for selected text with one key stroke. Put the following in your .emacs and you'll get something similar to CTRL+ALT+G in Eclipse.
;; my eclipse CTRL+ALT+G replacement (defun grep-selected (start end) (interactive "r") (grep (concat "grep -nH -e " (buffer-substring start end) " * .*")) (global-set-key "\C-\M-g" 'grep-selected)I am just learning to customize emacs with Elisp so I'm sure there are improvements that can be made.
- Magit in Spacemacs (evil-magit) notes — posted 2018-11-02
- Switching from Emacs to Vim (actually Spacemacs) — posted 2015-12-31
- Colorized, interactive "git blame" in Emacs: vc-annotate — posted 2011-05-28
- My Emacs Python environment — posted 2010-05-10
- Emacs espresso-mode for jQuery — posted 2010-03-10
- Notes on C++ development with Emacs on Ubuntu Linux — posted 2009-07-08
For a code completion the Eclipse has the same functionality like emacs ,Hippy competition (keybinding is "Alt +/").
Konstantin, thanks for the tip!
Kill buffer: C-x k
Close window: C-x 0
James, Thanks for the correction. I updated the table above.