
Concepts The Emacs Newbie Should Master - pdelgallego
http://benjisimon.blogspot.com/2011/04/10-concepts-emacs-newbie-should-master.html
======
ekidd
If you're using Emacs and git, you might want to look into magit, which allows
you to touch-type through common git operations. If you commit a lot, this
will speed you up significantly.

<http://philjackson.github.com/magit/>

I use custom Elisp to combine magit, git-blame, and other commands into a
unified git environment:

[https://github.com/emk/elisp/blob/5db6db4e7d96a3ef1c0a5fee76...](https://github.com/emk/elisp/blob/5db6db4e7d96a3ef1c0a5fee762f41b3da99f1d9/git-
tools.el)
[https://github.com/emk/elisp/blob/5db6db4e7d96a3ef1c0a5fee76...](https://github.com/emk/elisp/blob/5db6db4e7d96a3ef1c0a5fee762f41b3da99f1d9/dotemacs#L162)
[https://github.com/emk/elisp/blob/5db6db4e7d96a3ef1c0a5fee76...](https://github.com/emk/elisp/blob/5db6db4e7d96a3ef1c0a5fee762f41b3da99f1d9/dotemacs#L362)

It's especially handy to be able to pull up git-blame information for the
current buffer with just a few keystrokes. This turns your git commit messages
into a layer of hidden code comments.

~~~
davnola
I love Magit, but don't miss git blame: vc-annotate works really well. P and N
navigate the git history of the buffer.

~~~
technomancy
Yeah, magit isn't meant to replace vc; it just supplements it for the
operations for which vc is awful.

I've got to say though; seeing that article explain how Emacs helped him use
RCS and how it also has support for CVS and SVN really does _not_ help the
"Emacs is from the 80s" stereotype. Especially ironic since magit is the best
git UI I've seen anywhere.

------
silentbicycle
The post has many good suggestions! To them, I would add:

The mark ring. Whenever you place a mark (highlighting a region), its place is
also added to a ring, and you can jump between them by pressing "C-u space"
(or "C-x space" for pop-global-mark, which will jump between buffers). Many
commands that move a long way add an implicit mark, so this works quite well
as a "where was I..." command.

For "dynamic abbreviations", I recommend pabbrev
([http://homepages.cs.ncl.ac.uk/phillip.lord/download/emacs/pa...](http://homepages.cs.ncl.ac.uk/phillip.lord/download/emacs/pabbrev.el))
- when Emacs is otherwise idle, it starts building a lookup trie of prefixes
to frequently used words, so it will suggest completions under the cursor as
you type. I love it.

I much prefer iswitchb to the default buffer switching system. YMMV.

Don't forget about learning Emacs lisp, either! It adds quite a bit of
flexibility to Emacs. It's kind of a crappy, backward Lisp dialect, but still
tremendously useful.

Finally, learn to use the help system. Emacs's naming is really idiosyncratic,
but it gives you several powerful ways to look things up, so you don't have to
memorize everything.

~~~
limmeau
Thanks for the pabbrev hint. Sometimes, Emacs reminds me of games like Diablo.
Half the fun is in finding new pieces of equipment and trying them out.

Like image-dired, ibuffer, yasnippet, ...

------
program
Missing examples:

 _C-x z_ , the command that repeat the last command for every 'z' you type.
This is in my opinion one of the most important feature of Emacs

 _M-s o_ , the 'occur' command that show all the lines that match a specified
regexp

File variables:
[http://www.gnu.org/software/emacs/manual/html_node/emacs/Spe...](http://www.gnu.org/software/emacs/manual/html_node/emacs/Specifying-
File-Variables.html#Specifying-File-Variables)

~~~
njs12345
C-x z is definitely useful, thanks!

~~~
hsmyers
First one you need to know is C-x C-c... then you are free to experiment and
learn to you hearts content...

------
davnola
2 concepts I think are missing from this list:

* Tramp for remote/sudo editing: <http://www.emacswiki.org/cgi-bin/wiki/TrampMode>

* emacsclient if you want emacs everywhere all the time: <http://www.emacswiki.org/emacs/EmacsClient>

------
gcv
This thread is hilarious.

The Universal Principles of Design (among other places) talks about the 80/20
rule — but Emacs is so powerful and customizable that no two people ever agree
on which 20% is the most important!

~~~
silentbicycle
Well, Emacs is very much "a day to learn, a lifetime to master". I've been
using it for years, have led sessions teaching other developers, and just
yesterday I discovered rainbow-mode (<http://julien.danjou.info/rainbow-
mode.html>). Before that, it was magit and halp.

------
billswift
I disagree with #2, now at least.

 _First rule of emacs: don't quit. Or, more specifically, don't shut it down._

I used to do this, but a few months ago I managed to really screw up a file I
was working on, but didn't notice the problem until after I had saved it. And
because I hadn't closed that emacs session for over a week, I couldn't even
revert to a backup without losing a week's worth of work (emacs normally only
creates a backup file when it closes). So for the last few months I close
every session every day when I quit for the night.

------
reedlaw
As far as buffer switching, I never keep hundreds of files open because when I
switch git branches it's hard to remember which buffers need to be reverted.
Instead I usually close everything, change branches, and then open up files as
needed. I find I can open files more quickly using IDO-mode than I could by
switching buffers (plus I often forget the filenames).

~~~
technomancy
If you use magit to switch branches it will automatically revert the buffers
that were changed.

~~~
reedlaw
That's nice. Although I really like using git-emacs.
<https://github.com/tsgates/git-emacs>

------
limmeau
I trade registers and the help system (especially hyper-apropos) for narrowing
and spellchecking.

------
calpaterson
Didn't know about dynamic-abrevs, and haven't learned how the kill-ring works
yet. Thanks

~~~
pama
Even though setup is messy, you might want to also consider auto-complete/yas
instead of dynamic-abrevs

------
neutronicus
Is there a way to kill something _without_ putting it in the kill ring? It's
probably my biggest pet peeve about emacs that there's no way to kill text
without emacs assuming that you want it somewhere else.

~~~
smanek
M-x delete-region by default (although you can bind it to anything).

I use emacs every day, and don't think I've ever used it though. Just put the
stuff you want to delete in the kill ring.

Why don't you want stuff in the kill ring? It takes some getting used to, but
I've found it's generally a good thing. You can always yank back previous
items in the ring with M-y too, so it isn't like your OS clipboard where
'cutting' something else means you lose access to the previous item on the
clipboard.

~~~
neutronicus
Because sometimes I want to cut A, delete B, paste A where B used to be, and
it's irritating to have to have that extra M-y in there.

Perhaps I should instead write a new command to kill a region, but then swap
the last two things in the kill ring. That's actually a good idea...

~~~
redfax
In addition to the other two solutions, you can also use registers:
<http://www.emacswiki.org/emacs/Registers>

------
ndaugherty18
For the ruby people out there you guys should try xiki (xiki.org). It extends
emacs with a bunch of cool commands via el4r.

------
JohnFritzen
viper-mode

~~~
Tiomaidh
Or even M-x terminal -> vim. :)

~~~
mahmud
Does eterm have all the capabilities needed to run a full-screen editor like
Vim?

~~~
jrockway
screen + irssi works OK. vim probably does too.

