How to create commands like cat and less, save tabs?

Is there any way to do cat, lessetc. print tabs instead of conversions to spaces? It annoys me when I copy the code from the terminal to the editor.

+6
source share
2 answers

Here I see two problems.

  • First, the destination editor can hide the TAB to the number of spaces. Some editor has a default function for converting TAB to number of spaces. If you disable this feature. The TAB character that you copied from the terminal will be copied as a TAB (instead of space) to the editor. Windows Notepad ++ has a similar feature Notepad ++ feature to remove tab as spaces. If you use vim, this page will be useful for vim tab and space conversion

  • The other source file in your case may be a tab as spaces, check this first. You can use cat -t filenameto see if you have a TAB in the source file or not. This command will display the TAB character as ^ I.

+1
source

, (. unix.stackexchange).

cat , , more.

0

All Articles