How can I indent my code in Emacs by 4 spaces instead of 2 for a bunch of files?

What's a smarter, automatic solution to include my code in 4 heap spaces? How to make sure tabify doesn't affect perldoc?

+2


source to share


4 answers


Well you need it

(setq-default tab-width 4)

      

Then



C-x h
M-x indent-region

      

This is very similar to this other question .

+4


source


I had serious problems with this: this is the solution I came up with for the 3-space rule.



;;;; Tab settings ;;;;
;Tab width is 3
(setq tab-width 3)
;Tab width is 3 by default..
(setq-default tab-width 3)
;Use spaces always.
(setq indent-tabs-mode nil)
;Jump by 3.
(setq c-basic-offset 3)
;this defaulted to 4 and had to be reset to 3. 
(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))

      

+2


source


You should find documentation for the mode you are using (for example Lisp mode, C mode, Perl mode) to set the desired indentation and for re-selection of the region (for example, in SLIME this is done with C-M-\

).

0


source


My cperl-mode seems to be indented (more precisely, not indented) POD fine if it has a newline character before =head1

or =pod

. perlpod

is talking:

Without this blank line before "= head1", many translators would not recognize "= head1" as the start of a Pod block.

0


source







All Articles