Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs: Insert tab instead of spaces

For several reasons I prefer to configure my editor to insert spaces when TAB is pressed.

But recently I discovered that tabs should remain as tabs in make files.

How do I insert tab (\t, not " ") without reconfiguring editors each time I need to write make files?

I use the following editors: Emacs, Kate, gedit, and the Visual Studio editor.

like image 772
pic11 Avatar asked Feb 28 '11 19:02

pic11


People also ask

How do I make tabs instead of spaces in Emacs?

Emacs normally uses both tabs and spaces to indent lines. If you prefer, all indentation can be made from spaces only. To request this, set indent-tabs-mode to nil . This is a per-buffer variable; altering the variable affects only the current buffer, but there is a default value which you can change as well.

How do I add a tab in Emacs?

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.

How do you add a tab character?

The tab character can be inserted by holding the Alt and pressing 0 and 9 together.


2 Answers

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.

like image 127
Wayne Conrad Avatar answered Sep 22 '22 17:09

Wayne Conrad


Emacs' Makefile mode takes care of where to insert tabs and spaces as long as you press the right keys at the right places. Either that, or I missed some details in the question.

like image 31
vpit3833 Avatar answered Sep 19 '22 17:09

vpit3833