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 ...
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!
...
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:‗
15
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 ...
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 ...
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 ...
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 ...
8
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 ...
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 ...
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, ...
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=...
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,...
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
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 ...
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, ...
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
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
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 ...
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 ...
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 ...
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 ...
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 ...
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
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 ...
3
votes
Is there a version of "strpart" that is aware of characters, rather than bytes
In lh-vim-lib, I'm doing it this way:
if exists('*strcharpart')
function! lh#encoding#strpart(mb_string, p, l)
" If we want a narrow contract
" call lh#assert#value(lh#encoding#strlen(a:...
3
votes
What is the easiest way to insert en dash in Vim?
Install my unicode plugin, enter Vim and type DASH followed by CtrlXCtrlZ to activate unicode completion.
(Note the -N in the description which shows the digraph to enter that character)
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
unicode × 81font × 10
encoding × 10
vimrc × 7
microsoft-windows × 7
regular-expression × 6
vimscript × 5
key-bindings × 5
insert-mode × 5
search × 4
gvim × 4
keyboard-layout × 4
substitute × 3
conceal × 3
digraphs × 3
terminal × 2
highlight × 2
macvim × 2
options × 2
macos × 2
whitespace × 2
iterm2 × 2
input-methods × 2
control-character × 2
multibyte × 2