Skip to main content
OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn more
29 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
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.1k
16 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.1k
12 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.1k
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
  • 26.4k
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.4k
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 ...
Martin Tournoij'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
  • 17.9k
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,...
grochmal's user avatar
  • 1,656
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
  • 50k
5 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
  • 28.9k
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

Printing unicode chars?

Send the buffer to the browser by converting to HTML, then print from there: :TOhtml | w | !open -a Safari % For example I have this in vim: If I type :ha I get this: But when I send it to the ...
Rian Rizvi's user avatar
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,237
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,040
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,943
4 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
  • 141
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.1k
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
  • 5,987
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

Latin Capital Letter Thorn

The answer was posted in the comments by @DJ McMayhem. :set enc? latin-1 So by changing it to utf-8 the text becomes readable. :set enc=utf-8
Martin York's user avatar
  • 6,592
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
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.1k
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
  • 28.9k

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