Today we will learn how to type in Vim mysterious and just rarely (and someone often-) used symbols, such as ½,?, £, ©, ®, ™, ",", etc. This is especially useful for people associated with typography, but not only.
For a set of these remarkable things there are many ways, some of them have already
been described on Habré . These methods are reduced either to installing special software, or to creating your own keyboard layout. You can also (in any case, under Windows) memorize magic combinations and type characters using Alt + digits_ on_digital_keyboard_if_sign.
In order to type these characters in Vim, you also need to memorize magic combinations. The only difference is that these combinations consist of two characters and are usually easily remembered with the help of mnemonics.
')
Spell 1. Digraph.In order to use this spell, your Vim must be compiled with the
+ digraph feature. You can check for this feature by typing
: version and searching for it in the feature list.
Cast a spell like this:
Ctrl + K {char1} {char2} . For example, in order to type
© you need to press
Ctrl + KCo , for
™ press Ctrl + KTM , and for a long dash (
- ) respectively
Ctrl + KM- . Most of the combinations are chosen to be easily remembered. Here are some more examples:
“ this is
Ctrl + K >> ,
½ is
Ctrl + K12 ,
± this is
Ctrl + K + - . These combinations are called, as you already understood, digraphs. You can set them yourself using the command
: digraphs {char1} {char2} {number} - {char1} and {char2} are the characters that you will type after Ctrl + K, a {number} is the Unicode character code. But the standard set of digraphs is large enough, so you will hardly have to ask your digraphs, except to assign a combination that you can understand more than the standard one. By the way, digraphs can be typed differently:
{char1} Backspace {char2} . But this only works if you have the
'digraph' option set up and the so-called Input Method is not used (if you do not know what it is, it is most likely not used).
The list of digraphs can be viewed by entering
: digraphs without parameters. The list will be quite extensive, so it makes sense to output it to a file, as follows
:: redir> filename | digraphs | redir END . Instead of a file, you can redirect it to a register, for example, in
"* like this:
redir @ *> | digraphs | redir END and then insert it somewhere.
Spell 2.This is similar to typing with Alt + numeric keypad, only instead of Alt, you need to press
Ctrl + V , and you can type numbers at least to the right even from the top row. The code within 0 - 255 can be typed in decimal form (no more than 3 digits), in octal (also no more than 3 digits, you must start with
o or
O ), in hexadecimal (2 digits, start with
x or
X ). If the character is cunning (just our case), and the code fits into 4 hexadecimal digits, then you need to type
Ctrl + V u numbers (without spaces), if there are not enough four numbers, then
Ctrl + VU numbers . For example, to enter
© you can type
Ctrl + Vu00a9 ,
Ctrl + V169 or
Ctrl + Vo251 . It makes sense to use this spell if Vim is compiled without features
+ digraphs .
Happy Vimming!