My primary editor is Emacs, but my usage habits and knowledge of features has barely changed over the last few years.
What are the Emacs features that you use on a daily basis? Are there any little-known Emacs features that you find very useful?
Edit: Made this into the recommended poll format...please put one feature per answer from now on.
Auto-complete words in your code based on what already exists in the buffers:
M-/
Keep hitting M-/ until you find the word you are looking for.
Cuts down tremendously on how much you type.
A not so well known feature that I find very useful is M-x align-regexp
. If you mark a region and execute it, you will be asked for a regular expression, and emacs will then line up the first match of that expression on every line, by padding with spaces (or tabs, if you like). For example, say that you have a list of variables in your code:
int a = 2;
int a_longer_variable_name = 73;
int i = 0;
Then you can mark those lines and to M-x align-regexp
and specify =
as the expression, and it will align it like:
int a = 2;
int a_longer_variable_name = 73;
int i = 0;
Maybe not the most important feature in the world, but I use it regularly, and it sometimes impresses non-emacs people. :)
M-x occur
This feature is very useful when re-factoring/analyzing code. It's one of the things that keeps me from becoming a Vim [1] user.
[1] http://en.wikipedia.org/wiki/Vim%5F%28text%5Feditor%29Anything [1]! It's a kind of Quicksilver / Launchy / slickedit / Ubiquity tool inside Emacs.
Out of the box it allows you to type a word or regex and presents you lists of matching:
And it's easily extensible, you can easily add Google suggestions, or grep / find / mdfind [2] tools (most of them being allready there).
With Anything, I don't need iswitchb
anymore, and I rarely use (ido-)find-file
, since most of the time the files I want to open are already in the recent files list or the current directory list.
It changed the way I use Emacs!
Org Mode [3] for project planning. From the home page:
Org-mode is a mode for keeping notes, maintaining ToDo lists, and doing project planning with a fast and effective plain-text system.
It comes with Emacs, and it has a great integrated, plain text, programmer friendly, builtin table & spreadsheet [4] engine! (Includig auto re-aligning and formulas.)
Smart Tab [5] makes your tab key smart. If you're at the end of a symbol it tries to complete it, otherwise it indents the current line / region.
It works great for me: it makes line indenting, region indenting and completion available near the home line.
[1] http://www.emacswiki.org/cgi-bin/wiki/Anythingself-insert, by far, imo.
Keyboard macros [1] are very powerful when dealing with list of stuff...I use them as often as possible.
[1] http://jamesthornton.com/emacs/node/emacs_487.htmlstring-rectangle (C-x r t) and kill-rectangle (C-x r k). They allow to add stuff in front of every line in a block of text or---vice-versa---remove such stuff.
Here's the rundown of my F-keys:
F1: Gnus. Takes some learning, but cut my daily email time down to 20 minutes.
F2: ansi-term. Fairly full featured terminal emulator with a mode where you can switch back into behaving like an emacs buffer for kill/yank/macro goodness.
F3: slime. Crazy good tool for hacking the good hack with Common Lisp.
F4: switch-to-buffer "scratch". The scratch buffer is a good place to do fancy Emacs stuff when you don't want to type in the mini-buffer (try C-j).
F5: compile. You don't realize how great this is until you also grok next-error and previous-error.
F6: visits the buffer I have usually associated with an SQL session, either in an ansi-term or using psql.
F7: w3m. Very slick, fast web browser. Perfect for searching documentation.
F9: Visit my todo file in org-mode. org-mode, like gnus, takes a while to learn, but you can go so damn fast with it, it's worth it.
F10: calendar. Not as nice as org-mode but I haven't switched over all the way yet.
F11: open the EMMS playlist. EMMS doesn't come with the usual upstream Emacs distribution, but it's a pretty reasonable OGG/MP3/etc player.
F12: I run ERC and bitlbee. F12 brings me to the chat buffer with all my contacts from Google Talk and AIM in it.
Insanely cool thing not on one of my F-keys: TRAMP. TRAMP integrates into the way emacs finds, reads, and writes files. You can use file names like /sudo::/etc/passwd to edit things as root without starting another emacs, or /ssh:jfm3@jfm3.org:foo/bar.html to edit files remotely without staring a remote emacs.
Generalized ompletion modes and facilities are useful too. I like completion.el, but there are several to choose from.
Definitely check out www.emacswiki.org. Tons of good ideas there. Good luck!
Elisp. While the language itself can be a little bit clunky (for a lisp) it is so nice to be able to extend or fix your editor on the fly when you need to do so.
dired (M-x dired) let me navigate folders by touch-typing, much faster than browsing in a GUI.
M-x find-dired
a lot. Useful for a getting a dired buffer containing a list of all the files (filtered by the Unix find command) in a directory, and its subdirectories, recursively. - ataylor
yasnippets [1]
Textmate-like snippet expansion functionality for Emacs.
[1] http://in.youtube.com/watch?v=18xYbPCJOhoPretty hard to limit myself to the single most useful feature, but I like this command that hasn't been mentioned yet: auto-revert-tail-mode
.
Open up a log file you’d like to monitor in emacs and then do M-x auto-revert-tail-mode. Emacs will automatically watch the file, just like POSIX tail -f
.
auto-revert-mode
. - js.
M-x re-builder
Interactive regular expression builder that shows you live in the current buffer just what the regular expression is matching. Great for working out what things might need to be escaped (e.g. () pairs) and whether there's hidden tabs in the whitespace.
When you're done you just cut-n-paste into M-x query-replace-regexp or similar.
Most of us are familiar with M-!
for running a quick shell command from inside Emacs. A somewhat lesser known facet of this function involves using a prefix command of 1:
M-1 M-!
This runs the shell command and inserts the output at point in my buffer.
But what good is that? It lets me insert text into buffers, but not interact with it in any significant way. What I really need is a way to get the shell to take input from my buffer.
Enter the cousins M-|
and M-1 M-|
. From the docs:
M-|
runs the command shell-command-on-region, which is an interactive compiled Lisp function in `simple.el'
M-1 M-|
runs a shell command on the region and replaces the region with the output of the command.
In general, I prefer to use features built into Emacs, but when there's no Elisp equivalent available, I can carry out text transformations I need simply and easily:
M-1 M-| perl -p -e 'y/a-zA-Z/n-za-mN-ZA-M/'
To rot-13 encrypt a region quickly, for instance.
(Incidentally, The keystrokes C-1
through C-0
and M-1
through M-0
are the same (by default) as C-u
1 through C-u
0, which makes it very easy to type in repeat arguments. Just hold down M and type in 1 and |, or hold down C and type in 7 and n.)
Flyspell-mode! "Flyspell enables on-the-fly spell checking in Emacs by the means of a minor mode."
Can be configured to check LaTeX documents and comments in some other languages (flyspell-prog-mode).
hippie-expand [1], best text expansion in emacs, binding it to TAB and it will always do the right thing (and also very customizable).
[1] http://www.emacswiki.org/cgi-bin/wiki/HippieExpandOrg-mode [1]. My whole life is in a massive, single .org file.
[1] http://en.wikipedia.org/wiki/Org-modeBookmarks. Emacs bookmarks are both named and persistent, two features that many editors fail to offer.
They are invaluable because not only can I save my place in a file, I can also bookmark a directory that will be opened with Dired. I use them to jump to my most visited locations on the file system, and my main Org Mode files. Having a bookmark which effortlessly takes me where I want to go prevents me from losing my focus while I click around in the Finder or Windows Explorer.
I manage large numbers of bookmarks by namespacing them - all of my Org file bookmarks start with 'org' for example. This makes it easier to find a bookmark with tab-completion.
How to use them:
C-x r m BOOKMARK <RET>
Set the bookmark named BOOKMARK at point (`bookmark-set').
C-x r b BOOKMARK <RET>
Jump to the bookmark named BOOKMARK (`bookmark-jump').
C-x r l
List all bookmarks (`list-bookmarks').
I'm still waiting for Visual Studio to introduce named bookmarks - you need to install ReSharper just to get numbered ones!
Though it's not an emacs feature, it's always worthwhile to point out to any newbies to remap their caps lock keys to control. Save those pinkies!
How about the newbie-friendly
C-h k
which shows the documentation for the command associated with any key.
Or
C-h f
which shows the documentation for any particular command, given its name (i.e. what you would type after M-x).
I find these to be very helpful while learning emacs.
C-h c
to describe a key command in the minibuffer. For instance C-h c C-h c
prints "C-h c runs the command describe-key-briefly" - Patrick
I'm not sure if
iswitchb
[1] is little known but it's something I use countless times everyday. It makes switching buffer that little bit easier. When you enter C-x b
to switch buffers iswitchb
allows you just to enter a unique substring of the buffer name to select it which can often just be a single character. It's hard to explain but easy to try and once you've tried it you'll never switch it off.
partial-completion-mode
[2] does something similar in that it can autocomplete any minibuffer commands. It works best if it give it a hint by typing any dashes in the commands. For example, for M-x yank-rectangle
I can use M-x y-r [tab]
and have it autocomplete.
And there's
TRAMP
[3] for opening files on remote machines, usually via SSH. It works a treat on Windows using plink.exe
from the
Putty
[4] package.
I like interactive SQL mode to give me command line editing and history while using sqlplus.
M-x sql-oracle
And I add the following to my .emacs file:
(defun my-sql-interactive-mode-hook ()
(setq tab-width 8))
(add-hook 'sql-interactive-mode-hook 'my-sql-interactive-mode-hook)
(require 'sql)
Now I can start a sqlplus session and I get C-up and C-down to navigate through prior sql commands (similar to shell mode). This requires sqlplus to be available.
M-x sql-mysql
, M-x sql-postgres
, etc, for just about any SQL database you're likely to be using. - ataylor
(setq truncate-lines t)
in my sql-interactive-mode-hook
, so emacs won't try to wrap wide table selects. - ataylor
Using ido for finding symbols in the current buffer: http://www.emacswiki.org/cgi-bin/wiki/ImenuMode
Speeding up navigation by adding shortcuts to jump 5 lines per keystroke:
;; Faster point movement
(global-set-key "\M-\C-p"
'(lambda () (interactive) (previous-line 5)))
(global-set-key "\M-\C-n"
'(lambda () (interactive) (next-line 5)))
But the single biggest productivity booster for me has been swapping numbers and punctuation when programming in C++: http://infolab.stanford.edu/~manku/dotemacs.html
C-s sometext
in most cases. Just pick something near the line you need. When it gets automatic, it's lightning fast. - Paul McMillan
Someone else mentioned keyboard macros, but provided a broken link.
That feature may seem inane if you've used it with other platforms. But keyboard macros in Emacs are far more powerful, or at least easy to access the power of, than any other system I have used.
You can start simply by typing "C-x (", then anything you do is recorded to be played back... which means searches, replacement, opening new files, and so on. Then when you are done you can type "C-x )" to end the macro, and C-x e to replay the last keyboard macro. If you want to execute a macro multiple times, you can do so by pressing "e" repeatedly after the first execution via "C-x e". You can also run name-last-kbd-macro to name it, then use insert-kbd-macro to save off the macro you just defined somewhere (like .emacs).
The real power of macros comes into play when you use multiple cut buffers (registers), to save away various fragments of text in the middle of a macro and re-use the parts elsewhere. You can for example have a macro that expects some key text to be in register A for insertion, perhaps a search term in register B, and some other text to append elsewhere in register C grabbed on the fly within the macro. Or of course use multiple registers like multiple clipboards, all within emacs - the key bindings are different than they once were, but the commands you want are copy-to-register and insert-register.
All that, and it's basically as simple as typing something once (carefully) and then having Emacs repeat what you were doing with very complex changes possible.
I have used the combination of keyboard macros and registers to do things as diverse as turn lines of words into multiple lines of code appropriate for the word on the line, repair damaged LDIF files from an LDAP system, or do various refactoring tasks.
apply-macro-to-region-lines
Which is bound to C-x C-k r
on my system. Emacs will go to the beginning of each line in the current region run the macro. - Shannon Severance
Numbering in macros.
In the new(er) Emacsen, 'F3' is bound to start recording a keyboard-macro and 'F4' is bound to end recording a keyboard macro (and to replaying the last recorded keyboard-macro).
Press 'F3' to start recording a macro.
Now: when pressing 'F3' again while recording the macro, a counter is inserted which is incremented each time you play the macro back.
I found this incredibly useful in a surprising number of situations.
Press 'F4' to stop recording the macro, and press 'F4' again as many times as you need to repeat the macro.
M-x rgrep
I've bound it to F4, I'm using it all the time to interactively greping for file in a recursive manner. Combine that with easy bindings for next-error (F9), previous-error (shift-F9) and you have struck gold!
It always makes my co-workers impressed how quickly I can find things. No tags needed and it's /very/ fast.
M-x shell to directly access the shell from emacs. When used with a split screen (C-x 3), it becomes very quick and easy to do things. No need to continually switch between programs.
M-x eshell
when running emacs on a Windows. It gives a more *nix-like experience over the native cmd.exe
shell. (Plus, you can execute elisp at the command-line.) - Ray Vega
I recently discovered C-u C-spacebar. Emacs keeps track of all the places you've navigated to, and this lets you pop off the stack (taking you to a place you were before you came to where you are). Extremely handy when chasing call trees in source code.
Select a block of code then M-; to comment/uncomment. If language is not recognized you will be prompted for correct character to use.
M-x gdb to test in the debugger while automatically moving through the source tree in other windows. Set break points by opening the source file and doing C-x on the appropriate source lines.
Compiling from within emacs, and then for each error, being able to visit the line of code causing the error with a keystroke.
My personal favorite is follow-mode
, it will make two (or three, or any number of) side-by-side windows act as one really tall virtual window.
The convenience function follow-delete-other-windows-and-split
will set up two side-by-side windows and start follow mode.
Concretely, using six windows spread out across two monitors (and a small, but readable font), I can see 882 consecutive lines of code. This gives me a distinct advantage when it comes to reading and understanding code.
How about Digit-Arguments for the next command. Before, I have always used Universal-Arguments via C-u but you can go much faster since Digit args are bound to both, Control and Meta.
Examples:
Most-used and most-useful features (for me):
navigational keyboard bindings (M-b, M-f, C-a, C-e, etc) work well for fancy keyboard layouts. You do not use Home
, End
, PgUp
, PgDn
, arrows, therefore there is no need to relearn touch-typing when, for example, on notebook these keys are placed in unusual places.
It works in console (emacs -nw
) as well as with GUI. And it works under Windows, Linux, Mac. You can use the same editor both in command-line and GUI environment on any OS.
It has server-mode
which allows an instant opening of new documents in the same editor environment.
It allows to view several documents (and/or different parts of the same document) simultaneously. It is especially useful for wide-screen monitors.
Embedded command-line (M-!).
version-control (C-x v v
- do the next logical version control operation on the current file.)
find, open, switch, create file, buffer (C-x C-f
, C-x b
) via
ido.el
[1]
C-x C-o runs the command delete-blank-lines
I know it is quite basic, but extremely useful; delete several blank lines at once, or (when cursor on nonblank line) delete any immediately following blank lines.
C-o
(open-line) to insert a blank line - Patrick
C-y M-y
Let you go through all the history of copy and paste. Just magical.
http://www.gnu.org/software/libtool/manual/emacs/Earlier-Kills.html
Something that can be very useful at times, especially when renaming a bunch of files: In a Dired buffer, type "e" for wdired-change-to-wdired-mode, which allows you to edit the directory using any of your normal editing commads: regex-replace, rectangle commands, etc on file names!
On a related note, the rectangle commands are also quite useful when you get used to them.
(dired-find-file)
(GNU Emacs 23) - J.F. Sebastian
(dired-toggle-read-only)
(which is the same thing) is bound to C-x C-q
. - monotux
The ediff- commands, there's a bunch of variations, up to and beyond merging a full directory tree.
M-x ediff [then tab to the variant you need.] While editing I use ediff-buffers frequently.
The | switches between vertical and horizontal layout, it's color coded to help see just which word/letter changed.
Another one of my favorites is the transpose-* family of functions. They allow you to instantly switch two units of text around the current position of the cursor. For example, tranpose-words
on key M-t
switches the word in front of your cursor with the one behind it, tranpose-chars
on C-t
does the same with characters.
Perhaps the most useful variants are tranpose-lines
(and especially the tranpose-line-up
and -down
variants of XEmacs) for moving lines around, and transpose-paragraph
which switches entire blocks of code instantly.
If you really master these commands and make them part of the "active set" of emacs features that you actually use all the time, you will find that they add a whole new flow to editing code.
And, important as always, it sure does impress people who don't (yet) know the power of emacs. :)
For those coding in C in large projects cscope [1] is etags killer. Mapping the shortcut
(define-key global-map "\M-." 'cscope-find-this-symbol)
in dot-emacs will make you forget about tags.
Of course you have to index your project but here is another helper:
(setq cscope-database-regexps
'(
("^path_to_your_most/used/project/directory/tree/regexp.*"
( t )
("path_to_first_indexed_tree")
("path_to_second_indexed_tree")
("path_to_third_indexed_tree")
("etc")))
Put it in your dot-emacs (there can be several entries for different projects) and (x)emacs will know where to look for symbols for current buffer, so you don't have to index whole project - just the modules you work on.
cscope greatly improves understanding and refactoring of C source in big projects. Every hit of M-. presents you an active list of symbol use with one line context.
[1] http://cscope.sourceforge.net/My vote goes to org mode plus remember templates,
;;Remember
(org-remember-insinuate)
(setq org-directory "~/org/")
(setq org-default-notes-file (concat org-directory "/notes.org"))
(define-key global-map "\C-cr" 'org-remember)
;;Remember templates
(setq org-remember-templates
'(("Todo" ?t "* TODO %?\n %i\n %a" "~/org/todo/TODO.org" "Tasks")
("Journal" ?j "* %U %?\n\n %i\n %a" "~/org/JOURNAL.org")
("Idea" ?i "* %^{Title}\n %i\n %a %:date" "~/org/JOURNAL.org" "New Ideas")))
The grep-find command
M-x grep-find
search a pattern in current directory files and subfolders
My grep-find command is customized like that :
(custom-set-variables
....
'(grep-find-command "find . -type f -not -name \".svn-base\" -and -not -name \"~\" -and \( -name \".html\" -or -name \".php\" -or -name \".py\" -or -name \".sql\" -or -name \".js\" -or -name \".css\" -or -name \".sh\" -or -name \".tex\" -or -name \"Makefile\" \) -print0 | xargs -0 -e grep -n -s -F ")
....
)
multi-occur-in-matching-buffers
Allows you to regex search inside of all open buffers that match a regex
selective-display aka code folding aka code summarizing [1]
Code Summarizing in emacs plain beautiful(not really code folding since you're not closing up just one or two functions). It allows you to display only code that has a certain level of indentation in front of it. So you can hit a button and only classes show up or pass an argument with M- then hit the button and only the classes and the function definitions show up. Makes moving around code just plain easy. This works incredibly well with python's enforcement of indentation.
[1] http://emacs.wordpress.com/2007/01/16/quick-and-dirty-code-folding/I find the Emacs Code Browser [1] to be very useful for browsing the large code base we have at work. I also Have to say the most useful feature is really elisp itself. While I think it sucks, it only sucks compared to scheme or another lisp variant. It is by far the most powerful, imho, scripting language built into any editor.
[1] http://ecb.sourceforge.net/tramp-mode (and/or Ange-FTP): it lets you view and edit files over SSH, FTP and other protocols as if they were local.
You may want to know that you can specify the port for FTP with "#" after the host name. At least it took me a while to find out...
(Especially useful with Zope, when you can remotely edit objects in the running instance over FTP and in the products over SSH)
C-x [left] or C-x [right]: Buffer switching.
(global-set-key [C-tab] 'next-buffer)
, do the same with [C-tab]
, [C-f6]
and [XF86Forward]
AND (global-set-key [C-S-tab] 'previous-buffer)
, do the same with [C-S-iso-lefttab]
, [C-S-f6]
and [XF86Back]
. Now Emacs reacts on "next/previous" tabs the same way as normal browsers .. and IE. (The XF86 keys are special for IBM ThinkPads) - klang
For me it's rectangles. Create rectangles by placing marks (C-space)
C-x r k (Kill Rectangle)
C-x r y (Yank Rectangle)
C-x r t (Prepend a prefix to rectangle)
C-enter
to start a rectangle, use the normal M-w
to copy etc. emacs-fu posted this as a tip, check it out! - monotux
[ESC] [ESC] [ESC]
just try it on a frame with multiple windows.
Have M-x shell open a new shell instead of putting the existing shell buffer in the foreground:
(add-hook 'shell-mode-hook '(lambda (&rest; ignore) (rename-buffer (generate-new-buffer-name "shell"))))
Turn off scrollbar and other UI stuff:
;; turn off scrollbars (if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1)) (if (fboundp 'tool-bar-mode) (tool-bar-mode -1)) (if (fboundp 'menu-bar-mode) (menu-bar-mode -1))
Put Backup files into their own directory:
(setq backup-directory-alist `(("." . "~/.emacsbackups")))
M-x customize-variable. Very useful for customizing emacs, also in combination with writing and customizing your own elisp functions.
Pre-canned color themes: http://www.cs.cmu.edu/~maverick/GNUEmacsColorThemeTest/index-c.html
If you want to get all commands to a particular keyword just use the apropos command.
M-x apropos
This is very helpful if you want to learn new features within Emacs or if you just want to find a command by a given keyword.
C-h a
- Vince
hexl-mode is priceless for examining/editing non-text files.
Flymake [1] is the tool I cannot live without when programming. Correctly configured with Makefiles (I even use flymake on Windows), you instantly see, on-the-fly, all the errors and warnings that your compiler can find.
And this tool is part of GNU Emacs by default.
[1] http://flymake.sourceforge.net/deft - inspired by Notational Velocity, it is now my favourite way of keeping notes from within Emacs.
http://jblevins.org/projects/deft/
re-builder
For me, it's got to be ediff - it's saved my life on a number of occassions.
I like using rcirc client. You just do M-x irc
.
Well, I used vim for years and recently I moved to emacs and I found it pretty amazing and useful that you can use an irc client from your text editor (not using irssi any more).
You can also add the following lines in your .emacs file to automatically connect to a specific IRC server or join specific channels.
(setq rcirc-authinfo '(("freenode" nicserv "your_nickname" "your_password")))
(setq rcirc-server-alist '(("irc.freenode.net" :channels ("#channel"))))
Here you cand find more infomations about rcirc Getting started with rcirc [1]
And of course there is M-x tetris
in case you are bored ;)
Many of these have been mentioned already, but here's my list:
auto-indent: I love that when I hit tab it automatically indents "correctly", regardless of the type of the file. Also, the fact that you have many options of indenting style!
elisp: I've written so many stupid little elisp functions... I love that I can just create a function that does exactly what I need... (Favorite: M-x bp-folgers-crystalyze: secretly replaces the meta-syntactic variable "foo" with folgers crystals)
indent-region: auto-indents any region. Tells you where your missing ; is immediately!
C-n C-f C-b C-p: I never use the arrow keys anymore. (To the point where I'm always annoyed that C-b gives "block quote" on SO...)
bookmarks: constantly editing .emacs? no problem.
Multiple frames, keyboard switching between frames and windows: I don't need to use the mouse!
Paren matching
comment-region: Uses mode-dependent comment syntax to comment out every line in a region.
M-i
This insert spaces or tabs to next defined tab-stop column. It alows me to align everything with a few key presses which if very useful when you want a nice code.
Example:
int i = 1;
GtkWidget *window, *label;
double *a, *b;
can become something like this:
int i = 1;
GtkWidget *window, *label;
double *a, *b;
Additionaly you can customize places where you want tab stop with:
M-x edit-tab-stops
dired! and in there: dired-mark-files-regexp
, dired-do-rename-regexp
and dired-do-shell-command
when editing (blog) texts: transpose-chars
(CTRL-t
). :-) a command i miss in most text editors.
when programming: python-mode
, its py-comment-region
and py-execute-buffer
(with setting py-which-shell
as local varuable).
dired-mark-files-containing-regexp
(%-g
) - ataylor
I switched from using nedit and vi to emacs (now Xemacs) for column editing and the AUTOs in verilog-mode [1]. cua-mode enables the familiar key bindings - specifically clipboard (undo-Z, cut-X, copy-C, paste-V) key bindings - it really helps to ease the transition to emacs because you can use the normal emacs key bindings at the same time.
Since then I have found many modes to make (x)emacs like the IDE Eclipse only better because I don't have the performance hit (memory and speed) and I don't have to work inside of an Eclipse project. Check-out CEDET [2].
[1] http://www.verilog.com/verilog-mode.htmlNot really an editor feature proper, but having a foot pedal to avoid " Emacs pinky [1]" is nice. My pedal has three buttons bound to Control, Meta, and Shift.
[1] http://en.wikipedia.org/wiki/Emacs#Emacs%5FPinkySome of these are really basic commands, but they do help me out a lot:
C-x C-e
to evaluate the expression. This is a true friend for emacs tweakers.C-l
and C-u 0 C-l
to jump cursor position to middle and top of screen. This is great for reading those long lonely log files. I also have key-binding for the latter since I use it so much.C-x b
and C-x C-b
to navigate those buffers real fast. Combine this with window splitting ( C-x 2
and C-x 3
) and you will do magic when showing off your log analysis to colleagues and managers... :)C-s
and try pressing C-w
a few times after. This is also one of the most productive, commonly used features of emacs. I myself was struggling with copy-pasting to the search field before I found this cool feature. C-g
shall return to the point where you started out from so no worries about that either.(global-set-key [S-left] 'windmove-left)
(global-set-key [S-right] 'windmove-right)
(global-set-key [S-up] 'windmove-up)
(global-set-key [S-down] 'windmove-down)
C-/
which is my personal favorite in emacs, since it reflects how easy it is to use in emacs and how we do not need a separate command for REDO, since it actually is the undo of the undo.These might sound too simple, but are really powerful features in everyday use.
C-l
repeatedly to cycle the current line between the center, top and bottom of the window. - akaihola
M-x toggle-truncate
let's me switch of line-wrapping as a quick outline mode. Not so useful when programming, but definitely so when editing docs or html.
Bongo [1]
Manage playlists and play music from within Emacs. Supports multiple different backends. It even supports streaming from internet radio. I use it to listen to internet radio feeds while working. Especially useful if working in a non-desktop environment.
[1] http://www.emacswiki.org/emacs/Bongofinder-list-keywords
This function shows all the keywords used in the packages within emacs. In other words you can find a lot of stuff in emacs that you never knew was there.
abbrev abbreviation handling, typing shortcuts, macros
bib code related to the `bib' bibliography processor
c support for the C language and related languages
calendar calendar and time management support
comm communications, networking, remote access to files
convenience convenience features for faster editing
data support for editing files of data
docs support for Emacs documentation
emulations emulations of other editors
extensions Emacs Lisp language extensions
faces support for multiple fonts
files support for editing and manipulating files
frames support for Emacs frames and window systems
games games, jokes and amusements
hardware support for interfacing with exotic hardware
help support for on-line help systems
hypermedia support for links between text or other media types
i18n internationalization and alternate character-set support
internal code for Emacs internals, build process, defaults
languages specialized modes for editing programming languages
lisp Lisp support, including Emacs Lisp
local code local to your site
maint maintenance aids for the Emacs development group
mail modes for electronic-mail handling
matching various sorts of searching and matching
mouse mouse support
multimedia images and sound support
news support for netnews reading and posting
oop support for object-oriented programming
outlines support for hierarchical outlining
processes process, subshell, compilation, and job control support
terminals support for terminal types
tex supporting code for the TeX formatter
tools programming tools
unix front-ends/assistants for, or emulators of, UNIX-like features
wp word processing
multi-web-mode - When you are editing mixed content (say a php file which might have a mix of html, php, css and javascript), it will enforce the correct mode relevant to the block of code that you are editing. e.g. if you are inside <script type="text/javascript">...</script> block, it'll automatically switch to javascript-mode
https://github.com/fgallina/multi-web-mode
org-mode - Org-mode is for keeping notes, maintaining ToDo lists, doing project planning, and authoring with a fast and effective plain-text system. You can use it as a GTD (Getting Things Done, note taker and web/PDF authoring. http://orgmode.org/
:-)
- monotux
M-x replace-string
This command unconditionally replaces all instances of the old string in the document starting at the current cursor position. lifesaver =)
syntax: M-x replace-string {old string} [return] {new string} [return]
M-%
- Patrick
Ctags support:
If you have a Ctags file, it will take you to the definition of the variable, very useful when working in a big project. (Certainly, Vim has similar functionality)
AUCTeX [1], for editing (La)TeX documents. Emacs+AUCTeX is the most powerful (La)TeX editing environment I've found.
[1] http://www.gnu.org/software/auctex/Check out company-mode.
Excellent completion interface.
be sure to try C-s and the C-o to filter the completion candidates.
My completion set up is here:
http://richardriley.net/projects/emacs/dotprogramming
zen-coding mode - expand CSS like selectors to generate html. e.g. expand:
div#page>div.logo+ul#navigation>li*5>a
to
<div id="page"> <div class="logo"></div> <ul id="navigation"> <li><a href=""></a></li> <li><a href=""></a></li> <li><a href=""></a></li> <li><a href=""></a></li> <li><a href=""></a></li> </ul> </div>
http://code.google.com/p/zen-coding/
It's amazing, that no one suggested this: kill-ring/undo-ring will transform your editing forever.
Some of my favorites:
The fastest way to checkin/out: M-x svn-status
@Ray Vega I think it is even better if you use hippie-expand. You can configure which functions, and in which order will be called to complete. Here is my list:
try-complete-file-name-partially, try-complete-file-name, try-expand-all-abbrevs, try-expand-dabbrev, try-expand-dabbrev-all-buffers, try-expand-dabbrev-from-kill
query-replace-regexp. The syntax sucks, but once you get used ...
Little known but useful:
M-x isearch-forward-regexp
Incremental regex search that you can edit while it runs to get the regex matches correct.
A feature that I have found very useful is that whenever you're using Tramp to access a remote server and then into dired mode on a folder on that server, you can upload files from your computer with a simple drag and drop.
I listed some of the packages I rely on most here:
Regularly used Emacs packages [1]
[1] http://richardriley.net/projects/emacs/dotemacsUbiquity. Not exactly a "feature" per se, but important nonetheless. You can log into pretty much any *nix machine in the world, and expect emacs to be there.
One very useful package is the BrowseAproposUrl stuff:
http://www.emacswiki.org/emacs/BrowseAproposURL
I added some functions to translate using google dictionary and google translate a bit easier.
http://www.emacswiki.org/emacs/BrowseAproposURL#toc5
Regular expression search backwards, just because it has a funny keystroke:
ctrl+alt+shift+5
M-x is the most useful feature
webjump [1]
Let's you quickly launch webpages with search terms. For example a google, wikipedia or flickr image search can be quickly launched in your favourite browser from emacs. Also you can easily hook up programming API searches.
[1] http://justinsboringpage.blogspot.com/2009/02/search-reddit-flickr-and-google-from.htmllock-mode! I very recently found this, and in combination with auto-revert-tail-mode emacs can easily replace most cusom tail-applications if youre in windows.
TFS + emacs [1] is one of the less well-known that I've been finding to be very useful. I can checkin/checkout files from codeplex, add or delete files, diff, rename, undo, etc.
Maybe not the single most useful feature, but very useful.
[1] http://www.emacswiki.org/emacs/MSTFSbrowse-kill-ring
keeps previous yank in a buffer for browsing
magit
interface with git (http://philjackson.github.com/magit/)
Incremental search. My S key on all my computers is always faded out C-s C-s C-s
For me, the single most useful feature is my .emacs file - there is a lot of power to be had in a scripted config.
Xslide [1] even if it is old is soooo useful in my day-to-day work when writing a lot of xslt code. Many features like automatic completion of end-tags to mention some. Run an configurable XSL processor e g Xalan to validate your xslt files.
C-x C-p will start the validation process and give you the exact line where syntax is wrong
[1] http://www.menteith.com/wiki/xslideM-x gdb
for debugger
M-x shell
for runing code
f9
- compile
f10
- recompile
and CUE
for C-c C-v C-x
for copy/past/cut