Sponsored Content
Top Forums UNIX for Dummies Questions & Answers help on vi (special characters) needed Post 302319405 by otheus on Monday 25th of May 2009 07:02:24 AM
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.
 

10 More Discussions You Might Find Interesting

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

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

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

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

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

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

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

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

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

10. 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
vi(1)							      General Commands Manual							     vi(1)

Name
       vi - screen editor

Syntax
       vi [ -t tag ] [ +command ] [ -l ] [ -r ] [ -wn ] [ -x ] name...

Description
       The  (visual)  editor is a display-oriented text editor based on The command and the command run the same code.	You can access the command
       mode of from within

       The following is a list of some of the commands.  See the vi Beginner's Reference Card and "An Introduction to Display Editing with vi"	in
       the Supplementary Documents, Volume 1: General User for more details on using

       Screen Control Commands

	    <CTRL/L>	 Reprints current screen.

	    <CTRL/Y>	 Exposes one more line at top of screen.

	    <CTRL/E>	 Exposes one more line at bottom of screen.

       Paging Commands

	    <CTRL/F>	 Pages forward one screen.

	    <CTRL/B>	 Pages back one screen.

	    <CTRL/D>	 Pages down half screen.

	    <CTRL/U>	 Pages up half screen.

       Cursor Positioning Commands

	    j		 Moves cursor down one line, same column.

	    k		 Moves cursor up one line, same column.

	    h		 Moves cursor back one character.

	    l		 Moves cursor forward one character.

	    <RETURN>	 Moves cursor to beginning of next line.

	    0		 Moves cursor to beginning of current line.

	    $		 Moves cursor to end of current line.

	    <SPACE>	 Moves cursor forward one character.

	    nG		 Moves cursor to beginning of line n.  Default is last line  of file.

	    /pattern	 Moves cursor forward to next occurrence of pattern.

	    ?pattern	 Moves cursor backward to next occurrence of pattern.

	    n		 Repeats last / or ? pattern search.

       Text Insertion Commands

	    a		 Appends text after cursor. Terminated by <ESC>.

	    A		 Appends text at the end of the line. Terminated by <ESC>.

	    i		 Inserts text before cursor. Terminated by <ESC>.

	    I		 Inserts text at the beginning of the line. Terminated by <ESC>.

	    o		 Opens new line below the current line for text insertion.  Terminated by <ESC>.

	    O		 Opens new line above the current line for text insertion.  Terminated by <ESC>.

	    <DELETE>	 Overwrites last character during text insertion.

	    <ESC>	 Stops text insertion.

       Text Deletion Commands

	    dw		 Deletes current word.

	    x		 Deletes current character.

	    dd		 Deletes current line.

	    D, d$	 Deletes from cursor to end of line.

	    P		 Puts back text from the previous delete.

       Text Change Commands

	    cw		 Changes characters of current word until stopped with escape key.

	    c$		 Changes text up to the end of the line.

	    C, c$	 Changes remaining text on current line until stopped by pressing the escape key.

	    ~		 Changes case of current character.

	    xp		 Transposes current and following characters.

	    J		 Joins current line with next line.

	    rx		 Replaces current character with x.

       Buffer Usage Commands

	    [a-z]n yy	 Yanks n lines to the [a-z] buffer.  Default is current line.

	    [a-z]n p	 Puts n yanked text lines from the a-z buffer, after the cursor.

       Exiting vi

	    ZZ		 Exits and saves changes

	    :wq 	 Writes changes to current file and quits edit session.

	    :q		 Quits edit session (no changes made).

       The command uses all of the same edit or commands as However, does not allow you to write the file. See

Options
       -t tag	 Specifies a list of tag files.  The tag files are preceded by a backslash () and are separated by spaces.  The tag option should
		 always be the first entry.

       +command  Tells the editor to begin by executing the specified command.	A useful example would be +/pattern to search for a pattern.

       -l	 Sets the showmatch and lisp options for editing LISP code.

       -r name	 Retrieves the last saved version of the name'd file in the event of an editor or system crash.  If no file is specified,  a  list
		 of saved files is produced.

       -wn	 Sets  the default window size to n.  This option is useful for starting in a small window on dialups.	The -x option is available
		 only if the Encryption layered product is installed.

       -x	 Causes to prompt for a key.  The key is used to encrypt and decrypt the contents of the file. If  the	file  contents	have  been
		 encrypted with one key, you must use the same key to decrypt the file.

Restrictions
       Software tabs using ^T work only immediately after the autoindent.

       Left and right shifts on intelligent terminals do not make use of insert and delete character operations in the terminal.

       The  wrapmargin option sometimes works incorrectly because it looks at output columns when blanks are typed.  If a long word passes through
       the margin and onto the next line without a break, then the line is not broken.

       Insert/delete within a line can be slow if tabs are present on intelligent terminals, since the terminals need  help  in  doing	this  cor-
       rectly.

       Saving text on deletes in the named buffers is somewhat inefficient.

       The  source  command does not work when executed as :source; there is no way to use the :append, :change, and :insert commands, since it is
       not possible to give on a :global you must Q to command mode, execute them, and then reenter the screen editor with or

See Also
       ed(1), ex(1), view(1)
       The Little Gray Book: An ULTRIX Primer
       The Big Gray Book: The Next Step with ULTRIX
       "An Introduction to Display Editing with Vi", Supplementary Documents, Volume 1: General User

																	     vi(1)
All times are GMT -4. The time now is 11:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy