I was a Microsoft fan because I was born in China. There was no Unix culture when I was young. My professor knew as much as I knew about Unix. Basically it’s nothing. I believed Microsoft Windows was the only platform worth developing software on. I believed Visual Studio was the best IDE in the world. I was so loyal to Microsoft that I used Visual Studio to edit the code running on Linux server in my first job.
Besides, computers scared me to death. I’m ashamed to admit now that when I graduated from university I didn’t know clipboard. If I need input duplicated texts, I typed them character by character. I chose an IT career simply for money.
My point is if a computer dummy like me can be good at Emacs in one year, you can do better.
Here is the structure of the article:
- Why Emacs matters? You can skip this part if you are familiar with Linux/Unix
- The key point of guide is take full advantage of Master’s work. Don’t re-invent the wheel
- The steps to master Emacs
- How to improve after grasping basics by learning from community and books
- What matters is people
- FAQ and Summary
- Introduction
- Why use Emacs (optional)
- Step by Step Guide
- Readings
- Knowledge management
- My favorite Emacs addons
- Emacs is a way of life
- Take action
- FAQ
- I’m Emacs dummy. How to start?
- Any documentation on Steve Purcell’s setup?
- Is Master’s setup too heavy weight?
- Any other setup you can recommend except Purcell’s?
- Which version I should use?
- As a Vi person, why should I turn to Emacs?
- Why some Vim users cannot accept Evil?
- I don’t like default key bindings
- Too many key bindings to memorize
- I am not comfortable with other people’s setup. Can I modify it?
- I’ve cloned the master’s setup but the package is not upgraded.
- I have some specific question about Emacs
- I got some error message when starting Emacs with master’s setup
- My own setup is more controllable
- Why I cannot add my own plugins into master’s setup
- How to use Emacs on windows
- What about code-navigation and code-completion?
- What about web browsing?
- Email?
- Why Emacs cannot download packages?
- As a greenhorn of Emacs, should I learn Emacs Lisp at first?
- After knowing the basics, what to do next?
- Do I need learn keyboard macros?
- What do you think “Emacs can do everything”?
- Contact me
- Summary
- Copyright
This article focuses on on “how” instead of “why”. But it is necessary to explain why Emacs is worth learning.
Many people regards Emacs as an old editor which lacks the cool features of modern text editors. This is totally wrong.
Emacs has long history and gives users maximum freedom to customize. So all the features beyond your imagination are already invented by third party package developers ages ago.
The only thing you need to do is to take full of advantage of those packages,
- You can patch a package without touching its code
- You can easily create a package repository mirror on your USB flash drives
Many popular editors don’t have above functions.
Emacs is developed with Lisp. Lisp’s unusual grammar determines that its users are senior developers who have mastered multiple languages. A developer’s first programming language is usually C/C++/C#/Java. His/Her second language could be a script language like Javascript/Python/Ruby. After mastering third or even fourth programming languages he/she might be tired of “normal” language and try something different like Erlang/Lisp/Clojure.
So lisp community members are experienced programmers and technology enthusiasts.
The IDE is optimized for a specific programming language or framework. Emacs is more effective for generic tasks.
For example, sometime I need consult other programmers on IRC or web forum. My workflow is,
- Paste the code to http://gist.github.com
- Ask questions at IRC on online forum and paste the code back into my editor
- Emacs has built in integration of IRC and web browser so my flow is very fluent
I’ve been using Visual Studio and Firefox for many years. Trust me, Emacs is simply better.
Here is a demo from Emacs master, abo-abo demo search replacement technology
By the way, “code completion” and “code navigation” of Emacs are good enough.
“Good” means 90% of the functionalities works with minimum setup. If you need force Emacs to compete with IDE on specific programming language, you need install extra plugins.
But sometimes it’s just impossible to make Emacs as 100% same as IDE. So you need compromise. If 100% is a impossible goal but 95% is reachable, then stop at 95%.
I know many people are too concerned on replicating the “intelligent” code completion of IDE so they totally ignore Emacs’ other killer features in code completion (energy saving, faster completion, fuzzy matching …).
Senior developers are already familiar with APIs. In large projects, new code usually use same APIs as old code. So they don’t care about the so-called “intelligence”. They care about more completions candidate could popup faster.
For example, web programmers need to write css/html/ javascript in one javascript file (google css-in-js and jsx). Emacs+ctags/gtags could auto-complete html and css code in javascript file.
Some conventions:
- “C” means “Ctrl” and “M” means “Alt”
- “M-x my-command” means press “Alt” and “x” together, enter “my-command”
Here are the steps:
- Install Emacs 26
- Don’t install any plugins
- Learn basic knowledge about environment variable and pipe
- Read the official tutorial
- Use org-mode
- The only hotkey you need learn in org-mode is TAB key
Use Emacs in this way for several days in order to understand:
- Why people love Emacs
- How Emacs interact with other programs
Steps to read tutorial
- Start Emacs with minimum setup. I suggest running command “emacs -nw -Q” in shell
- “M-x help-with-tutorial”
This tutorial takes half an hour. Not too much time for a life time skill.
Please do not skip it.
At minimum, you need learn help commands:
- “M-x describe-variable”, hotkey “C-h v”, display documentation of variable
- “M-x describe-function”, hotkey “C-h f”, display documentation of function
- “M-x describe-key”, hotkey “C-h k”, display documentation of function invoke by key
Most newbies need a notes taking tool. So Org-mode is the answer.
If you don’t start by solving real world problem you will lose interest soon. Many people started the journey by learning Lisp. They gave up in the midway.
Focus on your most critical issue only. Ignore other issues temporarily. Sometimes compromise is a better strategy.
For example, I always use Emacs in terminal because at the beginning my most urgent problem is to edit the file on the remote server.
After a happy year with Emacs, I’m curious why other people keep complaining that their Emacs issues, especially on OSX (font not rendered properly, window not maximized, cannot increase font size, etc). It turns out they are using GUI version while I’m using terminal version. My terminal application already take over and solve these issues perfectly.
This is the most important section!
I learned the lesson the hard way. At the beginning, I regarded Emacs as a toy. I dug around the internet for cool code I can copy.
That’s totally a waste of time if my goal is to become an Emacs master!
I should have used Steve Purcell’s setup at the beginning!
Please don’t repeat my mistake. Just follow Steven Purcell!
Let me be blunt. You are a newbie, you’d better study top geek’s code. Don’t try to be “creative” at this stage. You won’t create anything when re-inventing the wheel.
For example, some readers tell me that Emacs has too many hotkeys. They can’t memorize all of them. This is typical in newbies who assume that top geeks can remember more key bindings.
Wrong!
If you have studied any master’s setup, you will find that she uses Smex, as it is more efficient than pressing hotkeys.
Since Steve Purcell loves new technologies and update his setup frequently, it may be a little harder to follow him for beginners.
That’s actually great. I’m lucky to stick to his setup because pulling from his git branch gets me updated with the latest cool things in community.
When I say “on the shoulders of giants”, I’m stressing that you need set your standard higher. I’m NOT saying the master’s setup is “newbie friendly”. If it happens to be “friendly”, it’s just the coincidence.
This section is discussing the best way to be good, not the easiest way.
There is a difference between best and easiest. For example, a setup using Vim key bindings is NOT easy but definitely best.
If you are still not convinced, consider my reasons:
- Those giants are more intelligent than me. They are harder working than me. How can I reach their level as quickly as possible?
- The obvious way is to join them.
- If you can report a bug about the master’s setup, at least in that moment, you have proven you are better at a certain issue than the master.
- You will get guidance from the master when he/she analyzes your bug report.
For example, I learned some advanced Lisp skill by reporting a bug. The bonus is that bug report is actually a case study. Knowledge from such a case study is hard to forget.
I was inspired by Steve Yegges’ article. Here is the text quoted:
Go look over Paul Nordstrom's shoulder while he works sometime, if you don't believe me.It's a real eye-opener for someone who's used Visual Blub .NET-like IDEs their whole career.
After reading the text, I decided to be as good as Paul Nordstrom. It’s mission impossible considering who Paul Nordstrom is. The reason to set a goal I can never reach is to make me not to stop. Whatever minor task I take, I always ask myself how Paul Nordstrom will handle it. Is my operation efficient enough that Steve Yegge will be surprised?
For example, switch focus between sub-windows in Emacs is not efficient by default. I need press Ctrl-x O
several times to jump to a sub-window. After some investigation, I found switch-window. Press Ctrl-x O
plus number key to finish the operation. I kept searching and found window-numbering. ALT key plus number key is enough. That’s 60% productivity improvement. Alt key is still a little bit far away from my fingers. Another improvement is to use Evil-mode and evil-leader, I need only press comma key and number key to switch window.
I suggest focusing on Emacs only in order to take full advantage of communities.
For example, although Quora.com has lots of interesting stuff, do not read/subscribe/follow them unless it’s related to Emacs.
The average quality of discussion on Reddit is better.
GitHub is still top one social network for developers.
I know some hard core geeks turn to GitLab because the Github is bought by “evil” Microsoft.
I do use Bitbucket sometimes. But Bitbucket is not good at social networking.
Github is still my most favorite site for finding interesting projects and sharing knowledge.
For example, I could avoid the pain of maintaining my own emacs configuration by watching other masters’ repositories at Github.
Git services has same “watch” button at home page. But the quality of Github notification is at different level.
Planet EmacsLife is the best collection of Emacs related blogs.
Follow the question on specific topic instead general one. For example, “What’s the best Emacs addon” is more useful than “How to learn Emacs”.
Everybody can say something about a general question. But to answer a specific question, you need first-hand experience.
Even if you are only interested in general questions, starting from more practical question is still better. Find the people who provides the best and the shortest answer and follow her.
I use keyword “emacs lang:en” to search latest news. The reason to search English only twitter is that there are lots of Japanese post and I don’t know Japanese.
There is also Advanced Search in twitter (Winy Song provided this tip).
Insert “emacs-related-keywords site:stackoverflow.com” in Google search engine.
The quality on stackoverflow discussion is good but there are not many new questions there.
http://emacs.stackexchange.com is a Q&A site dedicated to Emacs.
Some videos are great.
For example, Emacs Org-mode - a system for note-taking and project planning is the best tutorial on org-mode. Carsten proved that org-mode is simple. The only thing to remember is pressing “TAB” key to expand a text node. That’s the killer feature of org-mode. Other stuff are bonus.
Youtube lists the best matched results at the top. So you will always see the same things. I suggest sorting the results by upload date.
EmacsWiki has all the tips you need for tweaking the Emacs. It’s actively maintained by the community.
People complains that it’s not properly organized so it’s hard to find the valuable information.
Actually, most documents on EmacsWiki is still far better than any other resources. Please be patient and read the full content at specific page.
I recommend Writing GNU Emacs Extensions by Bob Glickstein. I like his writing style and the way he organizes chapters.
Xah Lee’s Emacs Lisp tutorial is practical and easy to read.
Steve Yegge’s Emergency Elisp is short but it includes the necessary information for writing Emacs Lisp.
Don’t study the Lisp at the beginning until you are confident about your Emacs mastery.
I uploaded my setup onto https://github.com/redguardtoo/emacs.d.
GitHub is the most efficient way of knowledge management because you will never lose the setup.
GitHub is also a wonderful tool for sharing. I benefit a lot by sharing. People who use my setup are actually helping me perfect my setup. I am the first guy who benefits from a better setup.
For example, people reported that I mixed my personal stuff (email address, full path of my hobby project) into my setup which they need remove. They expected it usable out of the box.
So I re-organized it and placed private stuff into a independent file named “privacy.el”. That file is outside of my Emacs configuration. Then it occurred to me that in corporate environment it was not safe to store plain privacy.el on a shared computer without encryption. After some research, I found Emacs already provided a perfect solution since version 23.
In order to get the most benefit of sharing, you need make sure your setup is qualified to share publicly. Never mix your personal things into it.
I use Dropbox to back up documents. Since dropbox will synchronize the documents into the mobile devices, I can study Emacs when commuting.
They are not must-have addons. There are many other alternatives which are as good as the listed.
New users have two problems on plugins:
- use plugins out of maintenance
- use not-the-best plugins
So I list the actively-maintained-and-high-quality plugins to help newbies start:
Name | Description | Alternatives |
---|---|---|
Evil | convert Emacs into vim | none |
Org | Get Things Done (GTD) | none |
company-mode | code completion | auto-complete |
expand-region | selection region efficiently | none |
smex | Input command efficiently | none |
yasnippet | text template | none |
flymake | syntax check. | flycheck |
ivy or helm | a framework to choose candidates | ido |
js2-mode | everything for javascript | js-mode |
w3m | web browser | Eww |
simple-httpd | web server | elnode |
smartparens | auto insert matched parens | autopair |
window-numbering.el | jump focus between sub-windows | switch-window.el |
web-mode | everything for edit HTML templates | nxml-mode |
magit | Everything about git | None |
git-gutter.el | Mark the VCS (git, subversion …) diff | None |
Emacs people are basically people who are hacking Lisp code for fun. They get the job done in a creative way. For example, Sacha Chua mentioned that she let Emacs read the manual when cooking.
So what benefit can I get after knowing the Emacs way?
After mastering Emacs, I could not endure the default key bindings of Firefox. So I installed an addon Keysnail to convert Firefox into Emacs. That doubled my speed in browser navigation. As a web developer, I am doing the browser navigation thing everyday.
Then I realized that Keysnail was awesome because its developer mooz was awesome. I followed him and used whatever he used. His percol made all my operations (git, file navigation, database management …) under shell ten times faster.
Things that used to be important become trivial now. For example, I don’t care which text editor has better file explorer. Why should I use any file explorer if I am ten times faster in shell?
We are living in the world of science and engineering. I improve myself more quickly by sharing to the best, by learning from the best. Knowledge is not black magic. Hiding knowledge will make it stale.
All roads lead to Rome. It doesn’t matter which road you choose. What matters is walking on the road right now.
But please make sure you actually understand the key points of this article at first.
For example, do you realize that previous sections imply following actions:
- Find all the developers of the Emacs plugins I listed
- Follow them on Quora/Twitter/GitHub/Reddit
- Read all their old posts on Quora/Reddit
Go to https://github.com/redguardtoo/emacs.d and check the section “Install stable version in easiest way” in README.
Nope. Read its README and code comment. The header of the code file usually has some guide and the developer’s email.
No. It is lightweight actually. Masters know how to optimize their Elisp code.
For example, they use a technique called Autoload. It will load a module when and only when module is actually used. I’m 100% sure all the setup I mentioned has applied this technique.
I did search at github, here is the list of top ones:
- Bozhidar Batsov’s emacs.d
- Sylvain Benner’s spacemacs (Spacemacs focus on Evil, so it might not be good for non-vim users)
- Eric Schulte’s Emacs Starter Kit.
v26.1 is the latest stable version, it has been released for about a year without any big issue. It can be installed easily on any platform.
I’ve watched too many people failed because they started from un-stable version!
Evil, the best of the best!
It’s because their customized key bindings conflict with Emacs/Evil default key bindings.
The solution is to use Leader Key in both Emacs and Vim.
Please note in Emacs you need install a third party plugin for this solution.
The other solution is to stay inside the comfort zone of vim.
That’s totally fine if you are OK with the life without Org-mode and Lisp. ;)
Or maybe you can read the section “What matters is attitude”?
I am die-hard Vi user with 14 year experience. After realizing the potential of Evil and Leader key, I re-assign all my vim key bindings according to Emacs configuration.
Another more brilliant example is a guy who earning tons of Github stars.
ergoemacs if you prefer Microsoft’s key bindings.
Use Smex. It’s a myth that a Emacs guru must remember many key bindings.
Try to understand the master’s setup at first. Don’t make judgment too early. It’s easy to make judgment. But understanding needs wisdom and hard work.
For example, some people reported that there was some weird character at column 80 when editing a file. That’s actually a feature to remind the user not to create any line with width more than 80 columns. Here is the reason.
Remove the file .emacs in your HOME directory. The ~/.emacs.d/init.el has same functionality.
Please,
- read official tutorial
For example, google “emacswiki init.el” to understand what’s the init.el.
That message could be ignored. It’s just the warning message when Emacs can’t find some OPTIONAL command line tool.
If you need install that missing tool, search the list in my readme.
If you are sure it’s actually an error message,
- Run “emacs -nw –debug-init” in terminal
- Send the output to the author of the setup
- Please use bug tracker if possible
That’s what I thought at the beginning. After several months I realized that I could never be as good as a master like Steve Purcell if keeping this way.
While I spend several weeks to overcome some minor issues in Emacs setup, Purcell has already installed/developed dozens of cool plugins.
If I cannot win, the only strategy is to join him, that’s why I clone his setup and start to report bug for him. Here is first issue I reported. Besides, reporting bugs also gives me the opportunity to talk with the master.
So don’t run away from the master’s huge setup. Regard it as a challenge to improve yourself.
Though the quality of Emacs plugins are generally good, they may have compatibility issues. It’s usually because plugins are developed by different people. For example, both auto-complete and yasnippet will use TAB key to expand code. So there is conflict if I use both plugins.
That’s another reason to stick to the master’s setup at the beginning.
Install Cygwin!
When you have enough knowledge about environment variables and pipe. You can check My answer at stackoverflow to use native windows version.
At minimum, you need set the environment variables HOME and PATH if you prefer non-cygwin way.
Thanks to Clang && GNU Global, C++ is perfect now. Support for other languages are also good enough except Java and C#.
I suggesting you using IDE when dealing with Java and C# in big projects.
I strongly recommend Firefox plus Keysnail. This is the perfect solution for Emacs fans. Trust me, I’ve already investigated every solution.
Firefox v57+ broke some APIs so Keysnail’s development was forced to stop. You can use Google Chrome plus Surfingkeys instead.
I use Gnus. But there are many alternatives. If you have to fetch email from Microsoft Exchange Servers, you need Davmail.
I also use Popfile to sort emails. Davmail+Popfile is the best solution!
If you are living in North Korea, Iran or China, you need below command line to start Emacs:
http_proxy=your-proxy-server-ip:port emacs -nw
How to configure proxy server is not covered here.
NO.
Most people lose the interest in Lisp because there its strange syntax and there not many Lisp jobs.
That’s why I stress that you need avoid tweaking Emacs at the beginning. Please copy the master’s setup at first.
Unless you have seen how Lisp gets your job done, you will not have the enough stimulus to finish the its course.
Me, for example, never feel pressed to learning Lisp. Actually, my initial plan is being great without touching Lisp.
As a proof, please visit my github account. Check all the issues I reported at the beginning. As you can see, I know little about Emacs Lisp for a very long time.
Find your practical problem which only Emacs can do best. Trust me, Emacs is much more powerful than your wildest imagination.
Here is my example:
- When I use Wordpress blog, I use org2blog to post articles. It’s ten times faster than any other client.
- I installed cmake-mode to do the cross-platform development with cmake.
- window-numbering.el is useful when jumping focus between sub-windows.
- When I work for some huge projects, I use evil-nerd-commenter to comment code lines because I need deal with too many programming languages.
No. Emacs Lisp is enough.
But, studying the Lisp code created by macro does help to understand some interesting problems. So I suggest you learn keyboard macro after mastering Lisp.
I suggest being practical. Sometimes other tools are simply better in real world.
For example, a developer had difficulties to sort a big dictionary file with pure Emacs Lisp. It’s too slow.
After consulting with me, he found that the GNU Sort is much better in this case.
So be practical. Richard Stallman created a whole GNU ecosystem for you. Emacs is only one component. Why not take full advantage of the system?
Here is my twitter.
My blog is at http://blog.binchen.org.
Please don’t ask basic questions, since I’ve already shown you how to find the answer.
- Start from real world problem
- Follow the master
- Report bugs to the master you follow
- Read and practice while following master
This article is published at https://github.com/redguardtoo/mastering-emacs-in-one-year-guide.
Please use GitHub’s bug tracker instead of emailing me directly. GitHub notification mail is always in my first priority folder.
Emacs is actually a platform. Cool people keep appearing. I will update this article from time to time in the future.
This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.