216 points · by rodw · 14y ago · 110 comments
Hi-lock lets you specify regexes to highlight anywhere in a file; it's like domain-specific font-lock.
It's astoundingly useful in code review. For instance, given a giant blob of J2EE web handler code, I can eyeball one handler, recognize the annotation mapping the method to URL syntax, and then punch in a hi-lock regex to light up similar annotations everywhere in the file, then glance through the whole file looking for color patterns. I can read any of those functions and recognize the code that checks "am I an admin", hi-lock it, and then quickly spot any function mapped to a URL that doesn't check admin credentials.
That's just one tiny use case. I used hi-lock so much I ported it into our web-based code review tool. I converted one person to Emacs just to get that feature (my office would be thrilled if someone could point out the vim package that does the same thing).
CUA column editing (CTR-SPC arrow-arrow-&c type-type-&c) is probably my #2.
Late edit:
Holy hell how do you forget magit! Magit is a near-complete UI for git; it figures out what git repo you're working from, and then gives you up-to-date status on the contents of your checkout, spots untracked files, allows you to visually stage your commits, gives you single-key revert and a browsable repo history.
Magit is one of the rare Emacs extensions that not only improves Emacs but also the external service it integrates with. I am actually a better git user (or, git is just better) when I've got magit running.
Instead, I can either set myself up to look for patterns of colors (function --- red line --- shit no blue line!), or set myself to serendipitously discover things as I actually do read code.
I have never, ever, ever, ever figured out an Emacs "grep" that I liked enough to stop using find/xargs/grep from eshell.
There are some ack-modes for emacs, too, eg. https://github.com/nschum/full-ack
highlight LowVis ctermbg=233 guibg=233 ctermfg=240
syn region LowVis start="\s*log_" end=";" contains=LowVis onelinehttp://www.vim.org/scripts/script.php?script_id=2666
<Leader>r (regex) to add matches to the set of highlighted groups.
I am an emacs user, but have been doing some J2EE stuff for the last few months, and have been getting really annoyed by the IDE's lately, and I was wondering if it was a wise choice to go with emacs for Java too.
I still do all my real dev in Emacs and have more than once put hi-lock to good use there.
I'd rather eat a bug than use Eclipse.
https://github.com/dimitri/el-get
El-get can install and update elisp from git, svn, http, and EmacsWiki. (It also wraps ELPA and apt-get where packages exist.)
If el-get doesn't have a recipe for your favorite Emacs extension, please consider adding the recipe and pushing to GitHub. (It doesn't take long - most recipes are only a few lines long.) Don't forget to issue a pull request for the rest of us.
el-get made lots of sense back in the day when package.el only supported tromey.com, but now that there's a community repository I don't see the point.
http://stackoverflow.com/questions/1218390/what-is-your-most...
My favorite Emacs feature that I've learned about in the past year is Org-Mode. I use it now for just about everything.
I'd been searching for a lightweight, console/cli-mode outliner/task-manager when it occurred to me "surely emacs has something for this". It did, of course.
For several weeks I used emacs only for org-mode. Slowly but surely emacs started to take over my more and more of my editing tasks. Now I find myself not even bothering to launch X, but simply emacs from the Linux console (run level 3?). It's amazing how responsive a computer is when you're not using any gui at all.
I've since discovered that org-mode is pretty common gateway into emacs.
At work I regularly edit files on 10-15 remote machines. But I never ssh to them and run an editor. Instead I'll just visit them through TRAMP, run Magit to commit stuff that I've done etc.
Of course, sometimes I forget I'm working remotely, and hilarity ensues. The worst episode was in a recent school project. I thought "oh, I'll just finish this on the train". And then, when I got on the train, realized I had actually been working remotely. Oops.
Not only is it seamless editing, you can actually use tramp to "cd" into a directory on a remote machine using eshell.
Edit: Holy crap, it does. That's going to be useful.
Trite but true!
That's probably the killer feature for me.
If (like me) you are a Vim user, there is a plugin to replicate this functionality called YankRing. Highly recommended! http://www.vim.org/scripts/script.php?script_id=1234
C-x (
<type some magic />
C-x )
C-x e
M-x 99 C-x e
(play macro 99 times) C-u 0 C-x e
plays the macro until it rings the bell (e.g. runs out of buffer space or tries to forward-search for a name that doesn't exist. This is great when you don't know how many times it needs to be run.Actually, that would be M-9 M-9 C-x e or C-u 99 C-x e.
I'm actually surprised that someone hasn't gone through all the older questions looking for stuff to close, given how rigid their mods tend to be.
; Ask for y/n on all queries that normally ask for yes/no.
(fset 'yes-or-no-p 'y-or-n-p)ESC ESC ESC is a much better "get me out of here!" command to remember.
C-x r k to cut a rectangle, and C-x r t to add one filled with, for example, the comment symbol:
(C-space)this
to comment
C-x r t #
#this
#to comment
Regional undo/redo is a close second.
If you are using transient-mark-mode, you can use `C-SPC C-SPC` to active and deactive the highlighted region. That'll still leave a mark.
Multiple buffers, and windows against them.
Followed closely by mode-specific buffers (c-mode, etc.).
Buffers with command shells are the bee's knees. I love those things.
The downside is that if the symbol locations change in a file, you'd have to refresh it. :(
Transpose the current line with the previous line.
Also, emacsclient.
(http://www.emacswiki.org/emacs/UndoTree) Scroll down for screenshot.
And follow-mode on a monitor turned sideways is pretty funny. Doubles your vertical space (good for eyeballing logs and data dumps).