I have been an avid user of nano/pico since about 1999, and yes, many naysayers think it is crap for programming, but it works for me, and I like it.
That being said, one of the major issues I’ve had is that the Xorg select/paste always copies tab characters as the corresponding number of spaces. So, when I select text in one file, paste into another, I have to replace all the spaces with tabs.
Typically I paste into gedit first, do the replace there, then c/p into the file. This preserves the tabs.
(If you’re still wondering why I use nano, I just like having my editor accessible as long as I have server access. I never got used to vi, and nano is more than effective for me.)
I have always thought nano should be able to search and replace tabs and spaces, but I could never get it to work. Even without the gedit technique, I would typically just replace all double spaces to nothing, then manually insert the tabs. My workarounds, again, are generally sufficient. I have not NEEDED search and replace of tabs within nano, but today I decided I wanted to really find out if I could.
And it required some digging …
But, I finally found it: verbatim input!
Nano has a feature to disable character interpretation, and for one character, accept input literally.
To turn it on (again it’s for just the first character typed), hit alt-SHIFT-V (alt-V without shift may trigger x-windows menus), then just hit the tab key (it may or may not show a note that you’re in verbatim input mode).
You only need to do this in the search / replace prompts. Obviously, you can type tabs directly into the file.
So an example — let’s say you want to convert any instance of 8 spaces to a tab character.
Here is the command stack:
hit space 8 times, then hit enter
alt-shift-V (verbatim input)
hit the tab key, hit enter
Proceed as normal.
Hopefully this post is easier to find than the seemingly impossible digging I just undertook …