emacs - Why do I use it?


Over the past few years, the only text editor I've been using on Linux is emacs. Not because I wanted to. But after I joined the firm that I currently work for, I was trained in emacs. And I found it difficult to use initially. But then I decided that if every one else in the firm could use it and become an expert, then so can I. So I spend some time with the built-in emacs tutorial and I just learned it really quick.

To be a good developer, you need good tools. But is that enough? No. That is just one bit. The next bit is to learn to use the tool. Is that all? Nope. That is just the beginning. To become productive with your tools, you have to master them. This is not easy, but you get used to using an editor depending on your work flow and gradually become an expert in it.

That is exactly what happened. I would not call myself an expert. Because I still don't know emacs inside out. But I know the things that would help me be productive at work. The short-cuts to the commands that I tend to use daily are now part of my finger muscle memory. I don't even have to think what keys to press to do what I want. It just comes out. And the annoying part is that when I suddenly switch to using other word processors or text editors, the emacs short cuts that I've learned just doesn't work. And that is frustrating because certain things like going back a few words etc, are so often done in any editor and the emacs way of doing that is not used in any of the MS Windows based applications.

But I still love emacs as it has helped me read and write code in Perl, C++, csh and bash for all these years. And as long as I stick to working with this firm, I will have to use emacs as I don't want to spend time learning another editor. Learning how to use every editor in the market won't help you become productive. It only increases the number of things you have to remember. Be a master of one and you'll surely be a lot more productive.

To install emacs on your Linux PC (I use Ubuntu so the command below won't work on other flavours of Linux):
you@yourprompt > sudo apt-get install emacs

If you wanted to customize certain short-cut keys in emacs you will have to create a .emacs file in your home directory. It is lisp based.

I'm pasting some of the most useful ones below if you are interested in trying emacs:
; disable startup message                                                                             
(setq inhibit-startup-message t)

; highlight selections                                                                                
(setq transient-mark-mode 1)

; interpret ansi color codes and do not print garbage instead                                         
(ansi-color-for-comint-mode-on)

; don't use tabs for indenting                                                                        
(setq-default indent-tabs-mode nil)

; show column-number                                                                                  
(setq column-number-mode t)

; scroll line by line                                                                                 
(setq scroll-step 1)

; show other pair of parenthesis                                                                      
(show-paren-mode 1)


; global font colors                                                                                  
(global-font-lock-mode 1)

; to go to your other window don't use multiple                                                       
; key combinations. just ctrl+o                                                                       
(global-set-key "\C-o" 'other-window)


; override yes-or-no to y or n                                                                        
(fset 'yes-or-no-p 'y-or-no-p)

; disable backup : too much slow down                                                                 
(setq backup-inhibited t)

; disable auto save. just save more frequently                                                        
(setq auto-save-default nil)

; bring electric buffer - another name for                                                            
; interactive buffer. press enter on a selection                                                      
; and that window will open                                                                           
(global-set-key "\C-x \C-b" 'electric-buffer-list)


; shortcut for goto-line                                                                              
(global-set-key "\M-g" 'goto-line)

; a function to copy line                                                                             
(defun copy-line (arg)
  "Copy lines (as many as prefix argument) in the kill ring"
  (interactive "p")
  (kill-ring-save (line-beginning-position)
                  (line-beginning-position (+ 1 arg)))
  (message "%d line%s copied" arg (if (= 1 arg) "" "s")))

(global-set-key "\M-k" 'copy-line)


Happy learning.

Comments