Nano Tip: Make Pressing the Tab Key Add Spaces Instead of Tabs

The Nano text editor often gets a bad rap, but in reality for the non-biased it is lightning quick, easy to use, with a very low learning curve. Once you’ve been using it enough though, you might wonder why pressing <tab> adds an actual tab character, when most DevOps and coders will expect a series of spaces. Luckily, it is easy to make this change.

For a one off run, you can start nano like this:

nano -ET4

The ‘-E’ parameter will make nano use spaces, and -T 4 sets the tab size to four spaces.

If you want to make this change more permanent, just create (or edit) a ~/.nanorc file in your home directory and add these lines:

set tabstospaces
set tabsize 4

Now whenever you press tab in nano, it will automatically add 4 spaces.

For more information on this and other nano parameters, check out the man page.