Vim Tips Wiki
Register
m (Fixed formatting, added category)
(→‎Digraphs: I think :dig[raphs] should have been :digraphs)
(19 intermediate revisions by 7 users not shown)
Line 1: Line 1:
  +
{{TipImported
{{review}}
 
{{Tip
 
 
|id=51
 
|id=51
  +
|previous=50
|title=Entering german umlauts
 
  +
|next=52
|created=March 15, 2001 1:52
+
|created=2001
 
|complexity=basic
 
|complexity=basic
|author=Anonymous
+
|author=
|version=5.7
+
|version=6.0
 
|rating=175/52
 
|rating=175/52
  +
|category1=Encoding
|text=
 
  +
|category2=
To enter german umlauts (or any other of those weired characters) not available on your keyboard use 'digraphs':
 
 
}}
  +
==Digraphs==
  +
To enter "special" characters such as the euro or copyright symbols, or diacritical marks such as the German umlaut or accent grave, <code>digraphs</code> can be used.
   
  +
Digraphs work by pressing CTRL-K and a two-letter combination while in insert mode. For example, in insert mode type:
In insert-mode type for example:
 
 
<pre>
 
<pre>
CTRL-K "a
+
CTRL-K a:
CTRL-K ^e
+
CTRL-K e>
 
</pre>
 
</pre>
  +
to give &auml; and &ecirc;.
   
  +
You can also set the digraph option <code>:set digraph</code> (or <code>:set dg</code>).
which gives an '&auml;' and '&ecirc;' ('e' with a hat).
 
   
You can also set the digraph option:
+
With the digraph option set you can enter
  +
<pre>
  +
a <BS> :
  +
e <BS> >
  +
</pre>
 
to give the same result.
   
 
To list the currently defined digraphs type:
:set digraph (or :set dg)
 
  +
<code>:digraphs</code>
   
  +
Here is a small extract from the <code>:digraphs</code> command:
With digraph option set you can enter
 
 
<pre>
 
<pre>
  +
Ct ¢ 162 Pd £ 163 Cu ¤ 164 Ye ¥ 165
" &lt;BS&gt; a
 
  +
e! è 232 e' é 233 e> ê 234 e: ë 235
^ &lt;BS&gt; e
 
 
</pre>
 
</pre>
which gives the same result.
 
 
To get a list of currently defined digraphs type
 
 
:dig[graphs]
 
 
For more information about defining and using digraphs refer to: {{help|digraph.txt}}
 
 
}}
 
 
== Comments ==
 
A little supplement:
 
 
German umlauts are: &auml;/&Auml;, &ouml;/&Ouml;, &uuml;/&Uuml;, and moreover there is '&szlig;'.
 
 
These are CTRL-K plus:
 
a" resp A"
 
o" resp O"
 
u" resp U"
 
ss
 
 
==== Examples: ====
 
#&Auml;hnlich = similar
 
#R&ouml;hre = tube
 
#m&uuml;de = tired
 
#Stra&szlig;e = street
 
 
==== Some french words: ====
 
#Ren&eacute; - popular first name
 
#Caf&eacute; - coffee house
 
#Amp&egrave;re - French physicist, 1775 - 1836
 
 
The 'e' with a hat (&ecirc;) is not german, it's french.
 
   
  +
The first two characters in each column are the characters you have to type to
&oslash;l in Danish is beer.
 
  +
enter the digraph.<br />
  +
In the middle of each column is the resulting character.<br />
  +
The decimal number is the normal Unicode number of the character.
   
  +
==By character value==
Joachim Hofmann (Schuttberg)
 
  +
It is also possible to enter any character (which can be displayed in your current 'encoding'), even a character for which no digraph is defined, if you know the character value, as follows (where ^V means "hit Ctrl-V, except if you use Ctrl-V to paste, in which case you should hit Ctrl-Q instead):
  +
*By decimal value: '''^Vnnn''' (with 000 <= nnn <= 255)
  +
*By octal value: '''^VOnnn''' or '''^Vonnn''' (with 000 <= nnn <= 377)
  +
*By hex value: '''^VXnn''' or '''^Vxnn''' (with 00 <= nn <= FF)
  +
*By hex value for BMP Unicode codepoints: '''^Vunnnn''' (with 0000 <= nnnn <= FFFF)
  +
*By hex value for any Unicode codepoint: '''^VUnnnnnnnn''' (with 00000000 <= nnnnnnnn <= 7FFFFFFF)
   
  +
'''<u>Notes</u>:'''
joachim.hof--AT--gmx.de
 
  +
* In all cases, initial zeros may be omitted if the next character typed is not a digit in the given base (except, of course, that the value zero must be entered as at least one zero).
, August 4, 2002 14:13
 
  +
* Hex digits A-F, when used, can be typed in upper or lower case, or even in any mixture of them.
----
 
The examples given have the key sequences reversed.
 
   
  +
==Combining characters==
As Joachim says, you enter a : for umlauted "a", not : a. This applies
 
  +
Vim knows how to work with [[wikipedia:Combining_character|combining characters]] as well as more traditional self-contained characters. A combining character is a character you enter separately from a preceding base character, which changes its meaning and is drawn in the same space. For example, 'ä' could be entered either as a single 'ä' character, or as an 'a' character followed by a combining ' ¨ ' character. By default, Vim accepts up to two combining characters for a given base character. You can use the {{help|prefix=no|'maxcombine'}} option if you need to use more.
to both Ctrl-K and digraph mode entry.
 
   
  +
You can enter combining characters using either of the methods given above, if you know the byte value or have a defined digraph. Once entered, however, it can be confusing to work with, since Vim mostly treats the base character and combining character as a single character. Using the {{help|prefix=no|'delcombine'}} option, you can work with combining characters separately in some contexts.
blaine.simpson--AT--admc.com
 
, April 28, 2004 9:18
 
----
 
Both the original entry here and Joachim say to enter
 
the letter to umlaut and " (double-quote). For my version of
 
vim at least, you use colons not double-quote, as you can
 
clearly see by giving the ":dig" command.
 
   
  +
See {{help|mbyte-combining}} for details.
umlauted a = a:, either Ctrl-K a : OR a &lt;BS&gt; : (latter if
 
digraph mode is on).
 
   
  +
Note that both the {{help|prefix=no|ga}} and {{help|prefix=no|g8}} commands will show you the combining characters used for a given character.
blaine.simpson--AT--admc.com
 
, April 28, 2004 9:25
 
----
 
alt+d seems to give me an ae too...
 
   
  +
==See also==
'''Anonymous'''
 
  +
*{{help|digraph-table}}
, September 25, 2004 7:25
 
  +
*{{help|digraph.txt}}
----
 
  +
*{{help|digraphs-changed}} Vim 6.0 and later use the [http://www.ietf.org/rfc/rfc1345.txt RFC1345] mnemonics.
I entered the set digraph command. How do you get it to work with &lt;BS&gt; syntax?
 
  +
*{{help|i_CTRL-V_digit}}
  +
*{{script|id=247|text=cream-ascii}}
  +
*[[Working with Unicode]]
  +
*{{script|id=2822|text=Unicode Completion Plugin}}
   
 
==Comments==
angel.sosa--AT--nationalcity.com
 
, June 15, 2005 8:59
 
----
 
[[Category:Encoding]]
 
<!-- parsed by vimtips.py in 0.701448 seconds-->
 

Revision as of 16:19, 23 October 2013

Tip 51 Printable Monobook Previous Next

created 2001 · complexity basic · version 6.0


Digraphs

To enter "special" characters such as the euro or copyright symbols, or diacritical marks such as the German umlaut or accent grave, digraphs can be used.

Digraphs work by pressing CTRL-K and a two-letter combination while in insert mode. For example, in insert mode type:

CTRL-K a:
CTRL-K e>

to give ä and ê.

You can also set the digraph option :set digraph (or :set dg).

With the digraph option set you can enter

a <BS> :
e <BS> >

to give the same result.

To list the currently defined digraphs type: :digraphs

Here is a small extract from the :digraphs command:

Ct ¢  162    Pd £  163    Cu ¤  164    Ye ¥  165
e! è  232    e' é  233    e> ê  234    e: ë  235

The first two characters in each column are the characters you have to type to enter the digraph.
In the middle of each column is the resulting character.
The decimal number is the normal Unicode number of the character.

By character value

It is also possible to enter any character (which can be displayed in your current 'encoding'), even a character for which no digraph is defined, if you know the character value, as follows (where ^V means "hit Ctrl-V, except if you use Ctrl-V to paste, in which case you should hit Ctrl-Q instead):

  • By decimal value: ^Vnnn (with 000 <= nnn <= 255)
  • By octal value: ^VOnnn or ^Vonnn (with 000 <= nnn <= 377)
  • By hex value: ^VXnn or ^Vxnn (with 00 <= nn <= FF)
  • By hex value for BMP Unicode codepoints: ^Vunnnn (with 0000 <= nnnn <= FFFF)
  • By hex value for any Unicode codepoint: ^VUnnnnnnnn (with 00000000 <= nnnnnnnn <= 7FFFFFFF)

Notes:

  • In all cases, initial zeros may be omitted if the next character typed is not a digit in the given base (except, of course, that the value zero must be entered as at least one zero).
  • Hex digits A-F, when used, can be typed in upper or lower case, or even in any mixture of them.

Combining characters

Vim knows how to work with combining characters as well as more traditional self-contained characters. A combining character is a character you enter separately from a preceding base character, which changes its meaning and is drawn in the same space. For example, 'ä' could be entered either as a single 'ä' character, or as an 'a' character followed by a combining ' ¨ ' character. By default, Vim accepts up to two combining characters for a given base character. You can use the 'maxcombine' option if you need to use more.

You can enter combining characters using either of the methods given above, if you know the byte value or have a defined digraph. Once entered, however, it can be confusing to work with, since Vim mostly treats the base character and combining character as a single character. Using the 'delcombine' option, you can work with combining characters separately in some contexts.

See :help mbyte-combining for details.

Note that both the ga and g8 commands will show you the combining characters used for a given character.

See also

Comments