Kys
Kys

Reputation: 2625

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

What is a more sane, automatic solution to tabbing my code by 4 spaces for a bunch of files? How do I make sure that tabify does not affect perldoc?

Upvotes: 2

Views: 3562

Answers (4)

jrockway
jrockway

Reputation: 42674

My cperl-mode seems to indent (or rather, not indent) POD fine, as long as it has a newline before the =head1 or =pod. perlpod says:

Without that empty line before the "=head1", many translators wouldn't have recognized the "=head1" as starting a Pod block.

Upvotes: 0

Paul Nathan
Paul Nathan

Reputation: 40319

I had massive issues with this: This is the solution I came up with for a 3-spaces 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))

Upvotes: 2

Trey Jackson
Trey Jackson

Reputation: 74450

Well, you'll need this

(setq-default tab-width 4)

Then

C-x h
M-x indent-region

This sounds very similar to this other stack overflow question.

Upvotes: 4

Svante
Svante

Reputation: 51501

You should look up the documentation for the mode you are using (e.g. Lisp mode, C mode, Perl mode) for setting up the desired indentation and for reindenting a region (e.g. in SLIME, this is done with C-M-\).

Upvotes: 0

Related Questions