65
votes
Accepted
See the Unicode code point of the current character
You can use %b or %B in statusline or rulerformat. From :help statusline:
b N Value of character under cursor.
B N As above, in hexadecimal.
For example:
set statusline=%b\ 0x%B
Gives you:
...
56
votes
Accepted
What is the easiest way to insert en dash in Vim?
You can use digraphs: Ctrl+k-N (with a capital N)
In Insert mode, digraphs are entered by Ctrl+k followed by a two-character sequence. For en-dash, the sequence is -N.
As Quincy pointed out, U+2014 ...
31
votes
Accepted
Can I search for a Unicode combining character in Vim?
Type in normal mode /<ctr-v>u0303
/ - start search
<Ctr-v>u - init utf-8 code input
0303 - hex code combine character.
:he unicode
Also :he mbyte-combining and :he utf-8-char-arg the ...
28
votes
Accepted
How do I keep accidentally creating a no break space before opening curly brace?
Others have already provided work-arounds, but as for the reason why it happens, I bet you're accidentally pressing Alt+Space.
I'm using Xubuntu with the 105-key Finnish keyboard layout myself, so ...
24
votes
Accepted
What is the easiest way to insert Unicode characters into a document?
Preface: This has nothing to do with Vim as such, but I will show you what I consider to be the "best" way to insert these characters by far; Vim's digraph system is more or less the same, but it only ...
20
votes
What is the easiest way to insert Unicode characters into a document?
To insert Unicode characters such as the euro or copyright symbols, or diacritical marks such as the German umlaut or accent grave, digraphs can be used.
For example, in insert mode press Ctrl+k and ...
20
votes
How do I keep accidentally creating a no break space before opening curly brace?
You can add an autocommand that replaces non-breaking spaces with regular ones upon saving particular file types, eg. by putting something like this in your vimrc:
augroup RemoveSpaces
autocmd!
...
15
votes
How do I keep accidentally creating a no break space before opening curly brace?
The 'listchars' option provides a means to make 'list' display non-breaking spaces. It's not set by default, so you probably want to add it.
set listchars+=nbsp:‗
14
votes
Accepted
What does CTRL-K do in insertion mode?
It allows you to enter a digraph — it's a method of entering a more extensive range of Unicode characters using pairs of keystrokes. (See :h digraphs)
For future reference, you can ...
13
votes
Accepted
How to translate Unicode escape sequences to the Unicode character?
If I understand you correctly, you have a file where certain characters are represented by their decimal value in the format \uXXXX, with X being any hexadecimal character but always 4, correct?
If ...
10
votes
What is the easiest way to insert en dash in Vim?
If there isn't a predefined digraph or you want a more memorable key sequence, then you can define digraphs in your vimrc. For example, the below will define two digraphs for en dash (8211) and em ...
10
votes
Accepted
move forward by a certain number of chars or bytes?
To go to the Nth byte in the file: use :go N, :Ngo, or Ngo (normal mode).
To move N bytes ahead, you could use something like this :exe 'go' line2byte(line("."))+col(".")-1+N
Unless you have ...
8
votes
What is the easiest way to insert en dash in Vim?
The standard way of inserting an en dash in Vim is to use a digraph, as tommcdo explained.
However, I find digraphs in general, and particularly this one (Ctrl+k, -, Shift+N) pretty awkward to type. ...
8
votes
What is the easiest way to insert Unicode characters into a document?
My unicode plugin allows for easy input of unicode characters. Specifically it allows
:Digraph <name> - Search digraphs for character
:UnicodeTable - Displays a characterset table
:UnicodeName -...
7
votes
Not able to type Unicode with Gvim and VIM on Windows 7
The default encoding seems to be latin1:
:set encoding?
encoding=latin1
When entering characters, Vim tries to convert them from the incoming character set (probably unicode) to latin-1. This ...
7
votes
Accepted
How can I get the character at the cursor position in a multibyte aware manner?
We discussed it less then 10 days ago on reddit.
One solution is matchstr(getline('.'), '\%'.col('.').'c.') which doesn't mess with any register.
I've put the resulting functions (we can ask for the ...
7
votes
Accepted
How to show illegal whitespace (such as unbreakable space) in source code?
List & Listchars
'list' is a boolean option that, when set, instructs vim to display whitespace characters. And it is completely customizable using 'listchars'.
For example, to show non-breaking ...
6
votes
Accepted
Why do symbols look ugly in gvim?
If you have a recent Vim, you may try to enable DirectX rendering. It should improve "wide" font rendering, among other things. Here's an example vimrc snip:
if has("gui_running")
set guioptions=...
6
votes
Accepted
(How) can I convert full-width characters to half-width ones?
There you go:
:%s/[\uff01-\uff5e]/\=nr2char(char2nr(submatch(0))-65248)/g
This matches the range of full-width characters, and via :help sub-replace-expr and char2nr() converts this to a number, ...
5
votes
Accepted
Digraph for the "bullet" (8226 hex 2022)
You can define your own digraph like this.
:digraph .. 8226
Or you could use the pre-existing digraph Sb which gives you Unicode 8729. Not the exact code point you were looking for but it is ...
5
votes
Accepted
Is there a version of "strpart" that is aware of characters, rather than bytes
Something like this should work:
function! Strpartw(src, start, ...)
return a:0 ?
\ join(split(a:src, '.\zs')[a:start : (a:start + a:1 - 1)], '') :
\ join(split(a:src, '.\zs')[a:...
5
votes
Accepted
Vim does not take umlauts as word characters
The @ character in iskeyword includes all characters for which isalpha() (C function) is TRUE; in modern (last 20 years) libc implementations this also looks for unicode characters.
Your second ...
5
votes
Accepted
Can I write Japanese (SKK) text in Vim?
OK, this took several days of struggle against the skk.vim plugin mentioned by @SatoKatsura. All the documentation is in Japanese therefore I still do not know of most of its features, and, certainly,...
4
votes
How can a character be inserted during an edit session by its Unicode numeric value?
Pressing <C-v>ude90 in insert mode should work.
The problem is probably:
let g:indentLine_char = <de90>
which is missing quotes; it should be:
let g:indentLine_char = "<de90>"
(...
4
votes
Accepted
How can a character be inserted during an edit session by its Unicode numeric value?
You are close. You need to use this form:
:let foobar="\u1234"
Using "\u" allows to use up to 4 hex digits. Until recently, it was not possible to use more, but with newer Vims you can now use "\U" ...
4
votes
What is the easiest way to insert Unicode characters into a document?
For commonly used characters, :digraph or external means such as the mentioned Compose key are great. For rarely used ones, I define abbreviations, like this:
norea <unique> unicode_smiley 😃
...
4
votes
Can I write Japanese (SKK) text in Vim?
Since I was in search for a good way to input unicode Japanese characters in
VIM, this post was really helpful. I tried using skk.vim but found it really
difficult, because contrary to the OP, I ...
4
votes
How can I get the character at the cursor position in a multibyte aware manner?
The following works and is faster than the matchstr() solution:
fun! Getchar()
return strcharpart(strpart(getline('.'), col('.') - 1), 0, 1)
endfun
nnoremap GG :echo Getchar()<CR>
See my ...
4
votes
How to interpret ASCII codes returned by "ga" command?
Vim is using Unicode (probably UTF-8), but Excel and/or Access are using Windows-1252 (or possibly a related Windows code page such as 1251 or 1253). Decimal 8216 is hexadecimal 2018, thus ‘ is ...
4
votes
Accepted
Can you match unicode blocks by name in vim?
Vim has its own regex engine and it doesn't support {Cyrillic}.
You probably want to read :h pattern-atoms and :h /character-classes to find out what you can use in your regexes.
I think the best ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
unicode × 72font × 10
encoding × 9
vimrc × 7
microsoft-windows × 7
regular-expression × 6
vimscript × 5
insert-mode × 5
key-bindings × 4
gvim × 4
keyboard-layout × 4
search × 3
substitute × 3
conceal × 3
digraphs × 3
terminal × 2
highlight × 2
macvim × 2
options × 2
macos × 2
whitespace × 2
iterm2 × 2
input-methods × 2
multibyte × 2
neovim × 1