Setting the tab size in nano tab_size tab-size (0k)

https://www.electrictoolbox.com/setting-tab-size-in-nano/

Setting the tab size in nano

Posted in Applications - Last updated Oct. 27, 2007

Nano is a text editor used on Linux and Unix based systems and is an enchanced free clone of the Pico text editor. By default the tab size in nano is 8 spaces, but it is possible to change the tab size either on the command line, in the system wide configuration file, or in a user specific configuration file.

From the command line you would do this:

nano -T 4 /path/to/file
OR
nano --tabsize 4 /path/to/file

It is more convenient to save the setting into a configuration file to save you having to type this on the command line all the time. This can be set either in the system wide configuration file (typically at /etc/nanorc, /usr/local/etc/nanorc or similar) or in a user configuration file at ~/.nanorc. Simply put the following into the file and the specified tab size will be used:set tabsize 4

In the examples above we are setting the tabsize in nano to 4 characters from the default 8 characters.

The order of precedence is as follows (and this applies to all of nano's settings):

system/nanorc (at eg /etc/nanorc)
~/.nanorc
command line

So, for example, if the system wide configuration specified a tab size of 4, ~/.nanorc specified a tab size of 8 but you entered nano --tabsize 2 on the command line then the tab size used would be 2. In this example, entering nano without a tabsize on the command line would use 8 (the user specified value), and if the user then deleted their .nanorc file it would be 4.

Last updated