How to Deal with the "TAB" in Emacs
As we all know, Emacs is a powerful editor.
(actually, it is far more than just a editor. = =)
But the TAB in Emacs is confusing.
In normal document edit mode, TAB equals 8 spaces. Just like this:
If there is some words in the upper line, TAB will let you stop at the same column of the second word of upper line. Just like this:
And if you continue tapping TAB, it will take you to the column of the next word of upper line.(you will stop at the same column of “i” in the example above.)
BUT!
In C mode, TAB is terrible. It only equals 2 spaces. Where is our friendly 4-space-TAB?
And the code in emacs’ C mode will be:
Maybe it looked not so bad, but most of the coders can not get use to it.
We want our 4-space-TAB back.
Fortunately, it’s easy to change the TAB settingã
If you want to change the TAB in C mode:
- C-x C-f to .emacs
- input (setq c-basic-offset 4)
- C-x C-s to save it
- reopen your emacs. and you will find 4-space-TAB in C mode
By the way, you can use any number to change 4 for you own needs.
And now, I believe that you can also handling TAB in other mode.