Normally I want nano to replace tabs with spaces, so I use set tabstospaces in my .nanorc file. Occasionally I'd like to use nano to make a quick edit to makefiles where I need real tab characters.

Is there any way to dynamically toggle tabstospaces? Most of the other options have keys to toggle them, but I can't find something for this. I've also tried using ^I (which by default is bound to the tab function) to insert a tab, but that honors the tabstospaces setting.

My current workaround is to take set tabstospaces out of my .nanorc file and to add shell aliases instead:

 alias nanotabs="$(which nano)"
 alias nano="$(which nano) --tabstospaces"

1 Answer 1


The shortcut that toggles tabstospaces is Shift+Alt+Q (or Meta+Q).
You will see the prompt changing to:

[ Conversion of typed tabs to spaces disabled ]


[ Conversion of typed tabs to spaces enabled ]

Another way (only for nano 1.3.1 or newer):
You can insert a literal tab if you enter Verbatim Input mode with Shift+Alt+V (or Meta+V).
If you then type Tab, nano will insert a literal tab character, irrespective of your .nanorc settings. It will then revert to regular input mode (so you'll have to enter Verbatim Input mode again if you need to type a second literal tab and so on).
You can also add your own Verbatim Input mode shortcut to .nanorc, e.g. Ctrl+T:

bind ^T verbatim main

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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