views:

341

answers:

4

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?

+4  A: 

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.

Trey Jackson
you mean tab-width of 4 right?
Kys
Duh, thanks.
Trey Jackson
It seems to not intepret perldoc effectively causing the =<something> to be indented as well
Kys
Correct, I can't find anything others have written which handles indentation ignoring perldoc (or at least treating it special). Kind of surprising...
Trey Jackson
A: 

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-\).

Svante
+2  A: 

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))
Paul Nathan
A: 

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.

jrockway