Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Is there a way to make cperl mode in emacs use all tabs for indentation instead of spaces? I've tried setting indent-tabs-mode, and cperl-tab-always-indent. Here is my .emacs file:

(defalias 'perl-mode 'cperl-mode)
(setq cperl-tab-always-indent t)
(setq inhibit-splash-screen t)
(cua-mode t)
(setq cua-auto-tabify-rectangles nil)
(transient-mark-mode 1)
(setq cua-keep-region-after-copy t)
share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

The right answer is not to use tabs. But ok, just for the sake of knowing how it's done…

CPerl uses the default Emacs settings for tab usage, and the Emacs default is to use tabs. So you're already getting tabs. Note that the default amount of indentation is 2 spaces, and the default tab width is 8 columns, so you need at least 4 levels of indentation to see a tab.

If you want to change the tab width to 2 columns, set the tab-width variable, but note that your files will look strange to other people with a different tab width. If you want to change the amount of indentation per level to 8 columns, set cperl-indent-level.

If you exchange files with other people, it's best to put these settings in a file variable (and not to use tabs, of course). For example:

# Local Variables:
# tab-width: 8
# cperl-indent-level: 8
# End:

I think the equivalent vi modeline is # vi: ts=8 sw=8:.

share|improve this answer
    
"The right answer is not to use tabs." obviously a holy war statement... considered modding down for that... –  xenoterracide Dec 15 '10 at 0:26
    
Thanks! That worked. I was confused because backspacing a tab in emacs converts it to spaces and deletes one at a time. To change it to delete whole tabs, I added this to .emacs: (setq backward-delete-char-untabify-method nil) –  sprale Dec 15 '10 at 2:20
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.