I cannot find this: How to use 4 SPACES instead of TAB in EMACS?

I am making the transition to EMACS, and I can’t find what I need to do in my file .emacsin order to get php mode, and insert all 4 other spaces instead of TAB in all other modes. Help?

UPDATE:

When I click the tab, I still get 8 spaces in the equal file with the given answers. In php mode, I still get 2 spaces. The tab tab in php mode does nothing, the tab in regular EMACS adds 8 spaces.

UPDATE2:

This is what I have in my .emacs:

(require 'color-theme)
(color-theme-calm-forest)

(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
(setq c-basic-offset 4)

There are still 8 spaces in regular files, but tabs in PHP files do not work or skip by accident. My php mode is from Ubuntu 9.10apt-get install php-mode


UDATE3:

OK. That's what I want ...

  • When I press the TAB key, and when I always press the TAB key, I want to add 4 SPACES.
  • , TAB ( , SPACES)

, () PHP .

+5
5

indent-tabs-mode nil. ( ) M-x set-variable. ( ),

 (setq-default indent-tabs-mode nil)

.

4 ,

 (setq-default tab-width 4)

C (, PHP) :

(setq c-basic-offset 4)
+9

(setq c-basic-indent 4). , :

;; 4 spaces rather than tabs
(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
(setq c-basic-offset 4)
(setq c-basic-indent 4)
+3

TAB Emacs ( ) - , , ( , , , , ). , , TAB .

, TAB , , . . -

(global-set-key "\t"
  (lambda ()
    (interactive)
    (let ((prevline-indent (save-excursion (forward-line -1) (current-indentation))))
      (if (< (current-column) prevline-indent))
          (indent-to prevline-indent)
        (insert "    ")))))

TAB , Emacs, Emacs, , . , - :

(setq-default indent-tabs-mode nil) ;; Prefer SPC over TAB when indenting.
(setq c-basic-offset 4)             ;; I like indenting by 4 spaces.

, , TAB php- , php-. , , , , , .

+2

M-x untabify .

indent-tabs-mode nil php.

You can also find the wiki: http://www.fnal.gov/docs/products/emacs/emacs/emacs_23.html#SEC185 and Jamie Zawinski post: http://www.jwz.org/doc/tabs-vs- spaces.html to be informative.

0
source

This is what I did.

;;;; Tab settings ;;;;
;Tab width is 3
(setq tab-width 3)
(setq-default tab-width 3) ;;going to force it. yessir.
;Use spaces always.
(setq-default indent-tabs-mode nil)
;Jump by 3.
(setq c-basic-offset 3)
;this defaulted to 4 and had to be reset to 3. the prior settings did not override it. Lame.
(setq perl-indent-level 3)
;Tab stop list out to col 60
;Manually set by x3
(setq tab-stop-list '(3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 51 54 57 60))
0
source

All Articles