Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I usually edit Python files with nano, so I need four spaces instead of a tab. How can I get nano to automatically insert spaces for tabs, and control how many of them it inserts?

share|improve this question
    
StackOverflow: tabs to spaces in nano –  Sven Rojek Aug 23 '13 at 7:00

1 Answer 1

up vote 10 down vote accepted

From the nano Command Manual:

-E, --tabstospaces
Convert typed tabs to spaces.

-T <#cols>, --tabsize=<#cols>
Set the displayed tab length to #cols columns. The value of #cols must be greater than 0. The default value is 8.

For four spaces, the appropriate command would therefore be nano -ET4.

Consider creating a permanent alias.

share|improve this answer
4  
you could also consider editing /etc/nanorc instead of making an alias. –  theTuxRacer May 6 '11 at 16:48
    
I feel like patching /etc/nanorc.... and uploading to fix this once and for all. With python3 not accepting mixed tabs&spaces this is silly to have tabs in python files in nano. –  Dima Aug 23 '12 at 16:46

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.