help on vi (special characters) needed


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers help on vi (special characters) needed
# 1  
Old 05-19-2009
help on vi (special characters) needed

How to add characters (not on the keyboard) with vi to a file?

Example:
How can I enter the copyright sign (UTF-8-Codetable: 169) with vi?
# 2  
Old 05-25-2009
You can use the :map commands. Vim understands UTF-8 and different file formats, and there are keymaps you can load with :set keymap=???, but for simplicity, you should be able to map your own key. Let's say you want to use CTRL-^ for the copyright character. First, you need to do
Code:
:set encoding=utf-8 fileencondings=

Then you can type the sequence
Code:
CTRL-V u 0 1 6 9

(no spaces here). If you are in text-mode vim (and not gvim), you will see a ? mark. Position the cursor over that question mark and type
Code:
:asc

On the status line, you will see:
Code:
<?> 361, Hex 0169, Octal 551

Bring this up in your HTML browser or whatever. If this isn't the character you expect, I don't know how to help.

Anyway, to map this to a keyboard character, say CTRL_^ you can do:
Code:
:map!  CTRL-VCTRL-^ CTRL-Vu0169

Now when you are insert mode, you can type CTRL-^ and you should see the ? mark. Do the :asc thing to make sure it's right. Finally, you can make an abbreviation so that typing (c) turns into this character:
Code:
:abbr (c) CTRL-Vu0169

That might be more intuitive in the long-run. If you need the sequence (c) without the abbreviation, you can type "(c)CTRL-V" and then a space, period, or whatever.

Note CTRL-V and CTRL-^ means holding down the Control key followed by V or ^ (often 6) or whatever.
# 3  
Old 05-27-2009
Hi otheus,

many thanks for your reply.

Unfortunately I'm working on Solaris with standard sysV vi Smilie
The ":set encoding ..." command is not available.
And therefore the sequence "CTRL-V u 0 1 6 9" is also not working.

So, I think I need to change to another editor ...
Anyhow: many thanks for your detailed explanation.
# 4  
Old 11-13-2009
aggiungere combinazione di tasti in vim

Buongiorrno a tutti,

sono nuovo di ubuntu.
qualcuno mi puo dire come si inserisce un parantesi graffa in vim?
e qualunque altro simbolo?

Grazie,
Matteo
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to replace special characters?

Hi Unix Guru, I have an requirement for replace some specail characters in a file, my file came from mainframe. please see below example: when open it with vi 17896660|89059215|04/24/1998 00:00:00.000000| abc 123-453-1312^M<85>^M<85>|124557 if I run cat -v I got following:... (25 Replies)
Discussion started by: ken002
25 Replies

2. Shell Programming and Scripting

Need help in replacing special characters

I am writing a ksh script. I need to replace a set of characters in an xml file. FROM="ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÛÚÜÝßàáâãäåçèéêëìíîïðñòóôõö¿¶ø®"; TO="AAAAAAACEEEEIIIIDNOOOOOOUUUUYSaaaaaaceeeeiiiionooooo N R" I have used the code- sed 's/$FROM/$TO/g'<abc.xml But its not working. Can anyone tell me the code to do this? (3 Replies)
Discussion started by: saga20
3 Replies

3. Shell Programming and Scripting

Replace special characters with Escape characters?

i need to replace the any special characters with escape characters like below. test!=123-> test\!\=123 !@#$%^&*()-= to be replaced by \!\@\#\$\%\^\&\*\(\)\-\= (8 Replies)
Discussion started by: laknar
8 Replies

4. Shell Programming and Scripting

special characters

Hey guys, I'm trying to replace "]Facebook" from the text but sed 's/]Facebook/Johan/g' is not working could you please help me with that? (6 Replies)
Discussion started by: Johanni
6 Replies

5. UNIX for Dummies Questions & Answers

How to see special characters?

Hi all, I was wondering how can i see the special characters like \t, \n or anything else in a file by using Nano or any other linux command like less, more etc (6 Replies)
Discussion started by: gvj
6 Replies

6. Shell Programming and Scripting

Special characters

When I open a file in vi, I see the following characters: \302\240 Can someone explain what these characters mean. Is it ASCII format? I need to trim those characters from a file. I am doing the following: tr -d '\302\240' ---------- Post updated at 08:35 PM ---------- Previous... (1 Reply)
Discussion started by: sid1982
1 Replies

7. UNIX for Dummies Questions & Answers

How to Remove Special Characters

Dear Members, We have a file which contains some special characters. I need to replace these special character by a new line character(\n). The Special character is \x85. I am not sure what this character means and how we can remove it. Any inputs are greatly appreciated. Thanks... (5 Replies)
Discussion started by: sandeep_1105
5 Replies

8. UNIX for Advanced & Expert Users

handling special characters

Hello everyone, I use Samba to copy mp3 files to my Red Hat 8.0 box so I can randomize them through a playlist. When I copy: Sigur Rós-Nýja Lagið.mp3 It shows in the mapped drive on Windows as: Sigur Rós-N_ja Lagi_.mp3 And via Putty as: Sigur R(grayed box)s-N_ja Lagi_.mp3 What is going... (1 Reply)
Discussion started by: effigy
1 Replies

9. UNIX for Dummies Questions & Answers

special characters

I have one file which is named ^? ( the DEL character ) I'd like to know how to rename or copy the file by using its i-node number TYIA (2 Replies)
Discussion started by: nawnaw
2 Replies

10. IP Networking

Special network tool needed

Hi everyone, I need some tool or a hint how to code it myself. I want a tool that listenes to a TCP/IP port and reads everything from that port and write it to a logfile. How can I do this? Regards, Steff (3 Replies)
Discussion started by: Tubbietoeter
3 Replies
Login or Register to Ask a Question