Editors
Since becoming a switcher in 2004 I exclusively did my work in Textmate. Early summer 2008 I started to explore other options. I spent a couple of months in Vim, MacVim to be precise, and really enjoyed it. After I got comfortable with MacVim, it's tabs and use of NerdTree for file management started to feel a lot like Textmate. That's not necessarily a bad thing, just not what I was really looking for.
emacs
During my Vim use, I launched emacs (Carbon Emacs) a few times and was turned off by the key combinations. However, the more I played with it, the more I liked it and the key combos quickly became a non-issue; almost second nature. If i wanted to cheat, i can turn on mac-key-mode for shortcuts that behave like Mac programs. Emacs runs on windows and linux so I decided to take the plunge and learn key combos the emacs way in case I have to jump to Ubuntu.
A Distraction Free Work Environment
For distraction-prone people like me, emacs excels in the full-screen department. When I think full screen I think Writeroom, Aperture and Lightroom, where everything is gone including the menu bar leaving me with nothing except the task I'm working on. This is something I could not effectively do with Textmate and I found myself constantly switching between Textmate and Terminal to get my work done, with an occasional jump to Twitterific, NetNewsWire and irc.
[Full-screen capture: this is all i see when I'm working in emacs.] [Full-screen: mouse-over menu bar] [Full-screen: alternate layout]Explanation of screenshots
Windows in emacs are backwards from what you expect them to be. Emacs calls the collection of windows or a single window a frame and a frame can be split horizontally or vertically in a number of ways to create multiple windows. Depicted in the screenshots I have everything I need. The top window is the code I'm currently working on. In the lower left window I have dired for my file management and terminal (or shell) in the lower right so I never have to switch between emacs and Terminal. The third screenshot is simply a illustration of another way I find myself splitting the frame.
Snippet for full screen toggling
I have my full screen toggle tied to the key combo Meta-[RET]. That's command+return on a mac. To use this add the following to your .emacs file and restart or refresh emacs.
;; full screen toggle using command+[RET]
(defun toggle-fullscreen ()
(interactive)
(set-frame-parameter nil 'fullscreen (if (frame-parameter nil 'fullscreen)
nil
'fullboth)))
(global-set-key [(meta return)] 'toggle-fullscreen)
In the coming posts in this emacs series I'll break down dired and the use of shell (or terminal) and how to use these tools effectively.
[Update: i've made my dotemacs available in case anyone wants to take a peek. Suggestions are welcome]











On Sunday, Nov 2
Nice post. I must admit that once I got my hands on this snippet, it was great. On my 17" screen, I can comfortably split a window so it tiles 3 wide by 2 deep. The biggest problem I have with that is that emacs's movement commands aren't as fluid as vim's. By saying that, I really mean I haven't figured out a way to configure emacs's movement keys to do what I want. :) Can't wait for the rest of these posts!
On Sunday, Nov 2
Thanks Jlilly.
On my 24" i do the same thing, split it many ways. On my 15" MBP i use one of the configs above. I do agree, it's a tad cumbersome jumping windows with keystrokes but I tend to use my mouse and/or trackpad for that so I haven't really found a need to come up with my own shortcuts... yet.
On Monday, Nov 3
In MacVim, just hit ⌘⇧F to toggle fullscreen mode.
On Monday, Nov 3
I never had good luck with full screen on my 24" monitor in macvim. It left a section of vim in the center of my monitor with scrollbars and about 5 inches on both sides of black. Wasn't very effective for me.
On Tuesday, Nov 4
Now you made me want full screen for GVIM! Derrrr....
Csmr
On Thursday, Nov 6
Nice article. I agree VIM rocks and full-screen mode is the best.
On Friday, Nov 21
Nice series. I just stumbled on your blog via github by way of del.icio.us.
Do you have code that puts emacs in those layouts? Or do you do it by hand each time?
On Friday, Nov 21
Hi Seth. Thanks.
The commands C-x-3 (control+x 3) will split your frame vertically and C-x-2 will split your screen horizontally. Within emacs you can do that as many times as you want provided you have a large enough monitor.
On Tuesday, Jan 6
Hi, I noticed you are using Adobe Courier as a programming font. Is that font included in Photoshop?
Thanks, great emacs series!
On Tuesday, Jan 6
Pedro.
It's actually Inconsolata Medium, not Courier. I'm not sure where I got it but pretty sure it's freely available. I use it for emacs, irc and terminal.
On Saturday, Feb 28
For those wondering how to get back to their favourite layout, remember that by pressing keys, you're just calling certain functions.
To find out which ones, do C-h k, and press they key combination you want info about.
Here goes an extract of my own .emacs:
(dired-other-window "~/src")
(split-window-horizontally)
(other-window 1)
(multi-term)
(other-window 1)
Here goes the lecture:
(dired-other-window) splits your window vertically, placing dired for the given path in the lower window, and activating it. I then split it horizontally (split-window-horizontally) to have one big window above and two below. I then go into the new window (other-window 1) and run (multi-term) in it. And then I swith back to the original big window, so I can edit away in *scratch*
One thing you might consider is setting your multi-term command to bash -l (slash L), which makes it read .bash_profile instead of .bashrc. But that's just my personal stuff, since I use .bashrc for aliases and it's sourced into .bash_profile, the main config file for my shell. If you're only using .bashrc, scratch this.
One thingy I've yet to try is giving arguments around for window sizes, so I don't have them all equalized.
@Greg: Thanks for sharing your dotemacs. I have to point out that I had to do several arrangements to make it load. Magit and Textmate in vendor are symlinks, so I got them and linked them. NxHTML wasn't present at all, got it also. To get textmate mode working, I had to rename the downloaded file to textmate-mode.el, to match the (provides) call inside, and then (require 'textmate-mode) instead.
I have to point out that troubleshooting this has given me a crash course on elisp tho, so it's not a bad thing ;)
On Thursday, Jun 25
Hey, what color theme is this? I like the purple...
On Thursday, Jun 25
John,
That would be inkpot which is bundled in emacs.
(color-theme-inkpot)
On Thursday, Jun 25
*arg* it wasn't bundled with my emacs! Thanks anyway!
On Thursday, Jun 25
What version are you running John? It's in my 23.x and Carbon which runs emacs 22.x
On Thursday, Jun 25
I have the following running: GNU Emacs 22.3.1 (i386-apple-darwin9.6.0, Carbon Version 1.6.0)