Operating System - HP-UX
1834397 Members
2749 Online
110067 Solutions
New Discussion

replace ^I caracter in ascii file?

 
SOLVED
Go to solution
Jorge Prado T
Contributor

replace ^I caracter in ascii file?

Hi,

Whit the VI editor, in an ASCII file, as I can replace the character ^I by blank ?

Thanks

Jorge Prado
3 REPLIES 3
Bill Hassell
Honored Contributor
Solution

Re: replace ^I caracter in ascii file?

^I (or CTRL-I) is actually the tab character, so you have lots of choices. The default vi behavior is to treat each tab as white space and to let the terminal move the cursor to the next tab stop (every 8 characters by default). To see special characters in vi, type the command:

:set list

and turn off this special character display,

:set nolist

One way to change all tabs to a single space:

:%s/\TAB/ /g

where the word TAB is really the tab key. The commands are:

: =invoke ed line editor
% =shortcut for 1,$ (all lines in file)
s =string replacement command
/ =beginning of pattern to match
\ =escape the next character's special meaning
TAB =the tab character
/ =end of source pattern, begin replacement pattern
=space character
/ =end of replacement pattern
g =repeat as needed across each line

Or you can convert the file instantly into the implied meaning of tabs (without vi) by using the expand command:

expand my_file > my_new_file

Now everything will line up correctly.


Bill Hassell, sysadmin
Kent Ostby
Honored Contributor

Re: replace ^I caracter in ascii file?

You can use cntl-V to set a cntl character.

So you could do:

:1,$:s/cntl-Vcntl-I/ /g

"Well, actually, she is a rocket scientist" -- Steve Martin in "Roxanne"
T G Manikandan
Honored Contributor

Re: replace ^I caracter in ascii file?

1,$s/cntl-Vcntl-l//g