February 25, 2008
This one is simple, but important.
To move the cursor left, right, up and down, use C-b, f, p and n respectively.
Page down: C-v
Page up: M-v
Beginning of line: C-a
End of line: C-e
See the point (no pun intended)? Don’t move your wrists!
Everytime you do, you waste a little time repositioning your fingers. You may be thinking that the amount of time wasted this way is very small. Well, I disagree. Sure, moving your hand takes only a few tenths of a second, but programmers need to reposition the cursor and scroll up and down ridiculously often.
I’m really surprised to see how many otherwise fast typers haven’t taken the time to learn these shortcuts. Really, it’s easier than you think, especially because you use these commands all the time. Getting used to the new shortcuts should take you a few hours of determination, at most.
February 21, 2008
My day job doesn’t include a lot of Lisp hacking.
On the positive side, though, this means that I’m free to redefine "M-C-p" (backward-list) and "M-C-n" (forward-list), because I never use them.
So here is today’s init.el addition:
(global-set-key "\M-\C-p" '(lambda () (interactive) (previous-line 5))) (global-set-key "\M-\C-n" '(lambda () (interactive) (next-line 5)))
I use a rather small font, so my 1600×1200 monitors can hold a lot of lines. This snippet allows me to move 5 lines at a time instead of one.
February 18, 2008
In the next few posts, I want to highlight a few productivity boosters that have worked very well for me.
First up: Numbers vs. puctuation.
A standard US keyboard is not designed for programming. You need to press shift to access most punctuation characters: Curly brackets, parentheses, double quotes etc.
So, this brilliant guy took the step and simply remapped the keys!
1 -> !
2 -> @
3 -> #
‘ -> ”
and so on (the numbers are, of course, accessed with shift).
This may sound impossible to get used to, but it’s a lot easier than you think! Sure, it takes a few hours and countless wrong keystrokes, but it really pays off.
Combined with the “electric” features of Emacs, this speeds up coding a lot. Try it out for a few hours and see for yourself.
By the ways, the mapping technique described on the linked page is not perfect. He simply swaps the keys with keyboard_translate, so keybindings that include numbers (eg. C-x 2) now require you to press shift to get the number 2. I’m working on improving this, but for now, I’ve just mapped C-x @ etc.
In general, keep a eye out for any keystrokes that tend for annoy you, or that you get wrong several times a day. For example, I use 2-4 windows per frame, and of course I need to switch between them very often. Therefore, the default shortcut, C-x o was just too slow, and I remapped it to C-o (M-C-o to switch frames, by the way).
February 9, 2008
Hello, and welcome.
This blog will be mostly about Emacs. For now, anyway. I have a feeling that, along the way, I will probably start blogging about other subjects as well. But for now, I’m writing about Emacs.
Note that my blog will not be for the Emacs newbie. Although I certaintly recommend investing the time needed to learn the basics of this wonderful editor, there are already a lot of great resources out there to get you started. For an excellent starting point, check out the Emacs wiki.
I hope that others will be able to make use of my experiences on my way to becoming an expert Emacs user. Feel free to comment away!
February 9, 2008
I use Subversion for a lot of my projects, and I’ve really enjoy the seamless integration in Emacs. Committing a file is as easy as C-x v v. However, vc-checkin is slightly broken. It needs a window in which to open the buffer *VC-log* (for you to enter the commit message in) and after you’ve entered a message and pressed C-c C-c, it closes that window. If you have only one window open in the current frame, it splits your window. Everything is fine…you get your one-window layout back. But if you have more than one window open, it steals an existing window and closes it. Quite annoying. So, I decided to fix this using vc-before-checkin-hook. The following hook opens a new window visiting the buffer *VC-log*.
(add-hook 'vc-before-checkin-hook #'(lambda () (set-window-buffer (split-window-vertically) (get-buffer-create "*VC-log*"))))
This way, the newly created window will always be selected and closed by vc-checkin, and predictability is restored.