Operating System - HP-UX
1833050 Members
2279 Online
110049 Solutions
New Discussion

special character to insert with vi

 
Admin.SIF
Frequent Advisor

special character to insert with vi

Hi,
help needed please : to insert character 1 in a text as exponent (or superscript or superior).
Any suggestion will be appreciated.
Thanks.
Sysd. Amin. Inforef
5 REPLIES 5
A. Clay Stephenson
Acclaimed Contributor

Re: special character to insert with vi

Sorry, that dog won't hunt. Vi is a text editor and it's word processing abilities are quite limited. UNIX's method of doing this is to embed macro's in the text and then a post-process (e.g. troff,nroff) does any fancy formatting --- and only with output devices that it understands.
If it ain't broke, I can fix that.
Admin.SIF
Frequent Advisor

Re: special character to insert with vi

And what about this ??

A. Clay Stephenson June 17, 2001 3:31:59 AM GMT 8 pts

--------------------------------------------------------------------------------
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

Sysd. Amin. Inforef
Mark Grant
Honored Contributor

Re: special character to insert with vi

There is a way to do this but only for output on a printer and ONLY if you happen to know the escape code for superscript for your printer. You embed this esacpe sequence in your document before your "1" and the sequence to turn it off afterwards. To get the escape character you will have to do CTRL-V and then press escape. Other than this, it isn't going to happen. Sorry.
Never preceed any demonstration with anything more predictive than "watch this"
A. Clay Stephenson
Acclaimed Contributor

Re: special character to insert with vi

That's not the same at all. Ctrl-V is used to quote non-printable characters (e.g. ESC,Ctrl-B, ...). Now, it is just possible that on some character sets on some terminals or printers, octal 005, for example, might output as a superscripted 1 -- but in the best case that would be a far from portable solution.

To get an idea of how UNIX does this (and it ain't pretty) try this:

cd /usr/share/man/man1.Z
cat ls.1 | zcat

That will display the formatting instructions for the ls man page and then compare that to the normal output of 'man ls'.
If it ain't broke, I can fix that.
John Meissner
Esteemed Contributor

Re: special character to insert with vi

I've used the ctrl+v followd by esc which will give you the following character
^[
and then you add your special character
as an example - to chane the color of your test (in Linux) you can use the following special character values:

black='^[[37;30m' # black on white bg
red='^[[37;31m' # red on white bg
green='^[[37;32m' # green on white bg
yellow='^[[37;33m' # yellow on white bg
blue='^[[37;34m' # blue on white bg
magenta='^[[37;35m' # magenta on white bg
cyan='^[[37;36m' # cyan on white bg
All paths lead to destiny