19

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.

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

Kusalananda
  • 320,670
  • 36
  • 633
  • 936
nath
  • 5,430
  • 9
  • 45
  • 87

2 Answers2

34

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

slm
  • 363,520
  • 117
  • 767
  • 871
3

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

αғsнιη
  • 40,939
  • 15
  • 71
  • 114