I want to override the bad default tabbing scheme in emacs so that it will work like most other editors (eclipse, notepad++). I want to set it so that regardless of mode, tab will insert a tab, and pressing enter will keep me at my current tab depth.
I tried this, but it does nothing:
(global-set-key (kbd "TAB") 'tab-to-tab-stop)
(setq default-tab-width 4) ;; 8 is way too many
To manually insert a tab in Emacs, use ctrl-Q TAB. control-Q causes the next key to be inserted rather than interpreted as a possible command.
The following commands can be used to switch between tabs: C-x t o. C-TAB. Switch to the next tab ( tab-next ).
If you want to remove tabs in an existing file, mark the whole buffer using C-x h and use M-x untabify .
To make the Enter key take you to the next line and indent it automatically, you can put
(global-set-key (kbd "RET") 'newline-and-indent)
in your .emacs
. [Or you can hit C-j
instead of Enter.] Once you have that, you'll never need to insert tabs manually, because Emacs automatically indents a new line to extra depth after an opening brace, etc. If you do want to change the indentation, you can hit TAB until it takes you to the right indentation, then start typing from there. [And when you type a closing brace, Emacs is smart enough to take that brace one indentation level backwards.]
You should remove the (global-set-key (kbd "TAB") 'tab-to-tab-stop)
for this to work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With