Skip to main content
30 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 ...
Ilmari Karonen's user avatar
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! ...
Endre Both's user avatar
17 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 ...
Rich's user avatar
  • 32.6k
16 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:‗
jamessan's user avatar
  • 11.2k
13 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 ...
Mass's user avatar
  • 14.4k
10 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 ...
D. Ben Knoble's user avatar
  • 27.7k
9 votes
Accepted

Replace nbsp with none string in utf-8 encoding in vim

You almost never need to deal with the binary UTF-8 encoding in Vim (or indeed, almost anywhere, including programming languages); for the most part you can just forget it exists as Vim takes cares of ...
Martin Tournoij's user avatar
8 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 ...
Luc Hermitte's user avatar
  • 17.8k
6 votes

Printing unicode chars?

Not trivially, but as a workaround, you can convert to HTML then print that from a browser. For example, on a Debian/Ubuntu-based Linux distro: :TOhtml | w | !x-www-browser % This might work for ...
Rian Rizvi's user avatar
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, ...
Ingo Karkat's user avatar
6 votes

Inserting the content of a register where a macro is recorded results in control characters becoming unicode characters

The ^[<80><fd>a sequence is a <Nop>, which means Vim recognizes this key sequence as valid, but it produces no action at all. The reason why Vim will insert a <Nop> right after ...
filbranden's user avatar
  • 29.9k
6 votes
Accepted

Inserting special characters like x̄ X̄ that aren't in the digraph table?

The issue with x̄ is that it's actually made of two separate characters, U+0078 (lowercase x) followed by U+0304 "Combining Macron". The Vim digraph system can only be used to insert a ...
filbranden's user avatar
  • 29.9k
5 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 ...
statox's user avatar
  • 50.6k
5 votes

Matching any Unicode whitespace

You asked for elegant, but got no answer... so here's the non-elegant way, listing all 25 characters defined as whitespace: \(\%u0009\|\%u000A\|\%u000B\|\%u000C\|\%u000D\|\%u0020\|\%u0085\|\%u00A0\|\%...
Thomas's user avatar
  • 151
5 votes
Accepted

Do not red underline unicode control points as misspelled words

As mentioned in the comment, the spell checking engine does work on the bytes in the buffer and therefore considers the combining characters as part of the item to spell check. Interestingly, ...
Christian Brabandt's user avatar
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 ...
aignas's user avatar
  • 141
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 ...
Lithis's user avatar
  • 1,050
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 ...
Ralf's user avatar
  • 9,417
4 votes
Accepted

Highlight Unicode Characters

With the help from Konfekt/vim-unicode-homoglyphs and the answers here I found this solution that works quite well and has (almost?) no performance impact: augroup Hiunicode autocmd! autocmd ...
laktak's user avatar
  • 2,983
3 votes
Accepted

Detect if Vim can show utf8 characters

You can test the 'encoding' option. For example I have this in my .vimrc if &encoding == "utf-8" if !exists("$PUTTY_TERM") && $OS isnot# "Windows_NT" exe "set listchars=nbsp:\...
Christian Brabandt's user avatar
3 votes

Printing unicode chars?

Per this Stackoverflow:4586628 Q/A, How do you pipe a vim buffer through lpr?, I have this entry in my ~/.vimrc: nmap PpP :%w !lpr -o lpi=8 -o cpi=14<CR><CR> that replaces my old entry, ...
Victoria Stuart's user avatar
3 votes

How can I get the character at the cursor position in a multibyte aware manner?

If you have the patch 8.2.2324, you can use the charcol() function in a :def function: def Getchar(): string return getline('.')[charcol('.') - 1] enddef nnoremap GG :echom Getchar()<CR> It ...
user938271's user avatar
  • 6,032
3 votes

Displaying terms as single character unicode symbols in VIM?

You can do this with Vim syntax's conceal feature, which allows you to hide matched text or replace it with a single character: :syntax match keyword "\<lambda\>" conceal cchar=λ :set ...
Rich's user avatar
  • 32.6k
3 votes

Can I write Japanese (SKK) text in Vim?

I'm trying to summarize here the experience of the other two users, while trying to keep it simple. Some issues were resolved (e.g. eskk now supports nvim). Also, I'm using pathogen which somewhat ...
x-yuri's user avatar
  • 359
3 votes
Accepted

How to express an unicode code points set in match command?

The syntax for unicode characters inside [] is different, you just omit the %: match ChineseMark /[\u3000\uff01-\uff5e]/ \%uxxxx is an atom while \uff01 is character in a collection. You cannot use ...
Mass's user avatar
  • 14.4k
3 votes

How to show illegal whitespace (such as unbreakable space) in source code?

You can use :syntax match ErrorMsg " " while inserting an unbreakable space between the "'s. To automatically load the rule, you can simply add au VimEnter,BufWinEnter * syn match ErrorMsg " " to ...
Daniele Santi's user avatar
3 votes
Accepted

How can I search for Unicode characters by hex code in very magic regexes in vimscript?

Turns out the "how" answer is very simple: In very-magic mode, % is already magical. Therefore, instead of \%u4e2d, %u4e2d (no backslash) works fine! In full, that's /\v%u4e2d<CR>
cxw's user avatar
  • 974
3 votes
Accepted

How to conceal zerowidth special characters like <U200C>

:syntax match ZeroWidthNonJoiner "[\u200c]" conceal cchar=😄 You need to check :h conceallevel, I set it to 2 personally. Otherwise, you may not get conceal to work as you expect.
oblitum's user avatar
  • 276
3 votes

Display superscript of multiple characters to express a mathematical exponent

Vim only ships digraphs for the superscripts for 1 through 3. You can find the additional superscripts for 4 through 9 and 0 in the Unicode ranges U+2074 through U+2079 and U+2070, which you can ...
filbranden's user avatar
  • 29.9k
3 votes

Vimscript to replace persian/arabic digits with english ones

Use the following :s command for Persian and Urdu digits: :%s/\([۰-۹]\)/\=char2nr(submatch(1))-1776/g And the following for Arabic digits: :%s/\([۰-۹]\)/\=char2nr(submatch(1))-1536/g
yukashima huksay's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible