Emacs personalization

emacs Personalize Emacs for what?

Emacs is a very powerfull tools when your start to develop in any kind of language. Usually you hear someone telling you that it is the best text editor ever, that it makes every things you could dream of and even more (the coffee, the laundry, ...). So you say (as a beginner like everybody), great I should to try it. So you download it (from the editor website, it is always better), choosing the more recent version for your operation system. You install it and you try to use it... You enter some text, as expected it work sbut if you try use any shortcut to copy/paste Ctrl+C/V or to save Ctrl+S, nothing commun work! Usually its always very confusing!

Then, two things append. One, you give up, too difficult to do very basic stuff and you don't want to spend you life to learn how to use this war-machine! Fine, that's up to you but you may miss something (to be honest that was my first reaction too). Second, you already have experience the first syndrom, and you decide to give it a real try this time! So you follow the tutorials and try to remember the maximum of shortcuts. Quickly, you will realize that you need to personalize you Emacs to fit your needs as much as possible. That were the real power of Emacs is! Your way, your Emacs.

I'm not planning to make a full description of the customization that you can do with Emacs, I just wanted to find a place where I can share my personal settings for my needs hoping that they can be usefull to others. These settings need to be store on you .emacs file (usually hidden in your home folder).

Restaure Copy Paste standard behavior

Emacs is nice, but after years with it, I still can not remember the copy/paste shortcut! So I use to activate the CUA mode M-x cua-mode to get the regular C-x to cut, C-c to copy and C-v to paste. You can also use that a default by adding this line in your ~/.emacs file:

;; Standard Copy/Past shortcuts
(cua-mode t)

Then Emacs will start to be kind with you !

Remove auto-backup

Emacs by default use to create a lot of backup files filename~ in your working directory. If there are not hidden you will doublicated file evrywhere (and that also can be security issue on a server if someone access it!). So to get rid of that you need to add this line in your ~/.emacs file:

;; Remove auto-backup files
(setq auto-save-default nil)

Web syntaxe colors in multiple languages

The syntax color is always a very quick and powerfull tool to read code. When you start web development you will use many languages at once (html, css, js, php, ...). To get a nice syntax color through all these languages (sometimes in a same file), I use the web-mode module. It can be found here. After download, you should store it in your ~/.emacs.d/ folder. Then add these lines in your ~/.emacs file:

;; Load packages directory [if not done before]
(add-to-list 'load-path "~/.emacs.d/")

;; Web Syntax color (HTML/CSS/PHP/JS)
(require 'web-mode)
(add-to-list 'auto-mode-alist '("\\.html\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.php\\'"  . web-mode))
(add-to-list 'auto-mode-alist '("\\.css\\'"  . web-mode))
(add-to-list 'auto-mode-alist '("\\.js\\'"   . web-mode))

I special thanks to Éric Thiébaut for showing me this great tool in the first place!