Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make commands like cat and less keep tab characters?

Tags:

cat

Is there a way to make cat, less etc. print tab characters instead of tabs being converted to spaces? I am annoyed by this when I copy code from the terminal to an editor.

like image 642
August Karlstrom Avatar asked Apr 11 '13 08:04

August Karlstrom


1 Answers

I am seeing two problems here.

  1. First, destination editor can covert TAB to number of spaces. Some editor has default feature to convert TAB to number of spaces. If you disable this feature TAB character you copied from terminal will be copied as TAB(instead of space) to an editor. Windows Notepad++ has similar feature Notepad ++ feature to remove tab as spaces. If you are using vim, this page will be helpful for vim tab and space conversion

  2. Another, source file in your case terminal may be representing tab as spaces, please check that first. You can use cat -t filename to see if you have any TAB in source file or not. That command will display TAB character as ^I.

like image 90
Baha Avatar answered Sep 28 '22 00:09

Baha