14

How can I search and replace horizontal-tabs in nano? I've been trying to use [\t] in regex mode, but this only matches every occurrence of the character t?

...just been using sed 's/\t//g' file which works fine, but I would still be interested in a nano solution.

1
  • 2
    I believe nano uses ERE and does not support the \t metacharacter. – jesse_b Jul 26 '18 at 21:11
20

In nano to search and replace:

  1. Press Ctrl + \
  2. Enter your search string and hit return
  3. Enter your replacement string and hit return
  4. Press A to replace all instances

To replace tab characters you need to put nano in verbatim mode: Alt+Shift+V. Once in verbatim mode, you can type any character in it'll be be accepted literally when in verbatim mode, then hit return.

References

0

In case Ctrl+\ doesn't work as expected, one may use Alt+R as alternative.

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.