Operating System - HP-UX
1753469 Members
5007 Online
108794 Solutions
New Discussion

Entering hexadecimal characters in vi

 
SOLVED
Go to solution
Nirupam
Occasional Contributor

Entering hexadecimal characters in vi

Hi,
can any one help me out how to enter the hexadecimal characters in vi editor such as hex(A2,A4) in one site they have mentioned that you have to get teh key strokes that will make up this charactes which are equivalent to this but I can't get any can any body help

Thanks in advance.
Nirupam
1 REPLY 1
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: Entering hexadecimal characters in vi

You can use the Ctrl-V ket to quote special characters in vi but entering values above
decimal 127 is difficult. If you know the keyboard mapping to generate the A2 hex code then you would (while in insert mode in vi)
enter Ctrl-V, your combination of keys, then ESC to end the insert.

But there is a better way and you don't have to know the keyboard mapping of your particular terminal:

Use two text files file1 - with your hex codes
build like this:
echo "\0242\0244\c" > file1

This will create a two byte file with the octal values 242 (A2h) and 244 (A4h).

Now in your main file (e.g. file2) You enter whatever text you want and position the cursor at the desired point and do a :r file1 to read the two characters into your file. You can then copy and move them wherever you like.

This should fix you, Clay

If it ain't broke, I can fix that.