Skip to main content
7 votes
Accepted

What is fileencoding of .vimrc?

It is whatever you define with :scriptencoding. It should be the first line in you .vimrc file, e.g.: scriptencoding utf-8 set number set ... However, as per the Help for :scriptencoding, if you set ...
Tae's user avatar
  • 2,135
7 votes
Accepted

Can I define a custom encoding for vim?

As romainl suggested, you can achieve so with the conceal feature of vim. Here is a script example that can be used: let rules = [ \ ['01' , '☺'], \ ['02' , '☻'], \ ['03' , '♥'], ...
nobe4's user avatar
  • 16.1k
7 votes

UTF-8 not working on VIM

GENERAL SETTINGS Vim internal use of encoding (this settings is must if you like to use utf-8 or you would like to convert encoding from one to another). I strongly recommend to set this setting in ...
folow's user avatar
  • 241
6 votes
Accepted

Specify UTF-8 encoding in Vimrc

It would be set encoding=utf-8, no quotes. set encoding="utf-8" would be an error because "utf-8" would be considered a comment, thus it would be the same as set encoding=. Vim does not actually ...
jamessan's user avatar
  • 11.1k
5 votes
Accepted

Can I change the encoding of the content of a file to show Chinese characters?

You could use something like this to convert to Unicode: %s/\%(\\u\x\+\)\+/\=eval('"'.submatch(0).'"')/g And back: %s/[^\x00-\x7f]/\=printf('\u%x', char2nr(submatch(0)))/g As a naive toggle ...
Tommy A's user avatar
  • 6,790
5 votes
Accepted

How can I detect the encoding of a file correctly?

Vim uses the first encoding that's considered "valid"; for multi-byte encodings such as UTF-8 this is more or less reliable since many documents are not valid UTF-8 documents (although it ...
Martin Tournoij's user avatar
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
Accepted

Encoding of the spellfile en.utf-8.add

Try reopening the file and forcing it to load in "utf-8" mode. You can do this with :e! ++enc=utf-8 % From :help ++opt *++opt* *[++opt]* The [++opt] argument can be ...
DJMcMayhem's user avatar
  • 17.7k
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

Can't copy special characters outside of vim

Make sure your locale contains the full UTF8 specification to a language; i.e. not something like en_US, but en_US.UTF-8. See this issue.
user938271's user avatar
  • 5,987
4 votes

Is \r operating system specific?

No, that is not true. Internally, \n will always match the line termination of a buffer regardless of whether the actual file uses <CR> or <NL> or <CR><NL> as line terminator (...
Christian Brabandt's user avatar
3 votes
Accepted

How to show the currents char code in ruler

There's an example under :help statusline: < Similar, but add ASCII value of char under the cursor (like "ga") > :set statusline=%<%f%h%m%r%=%b\ 0x%B\ \ %l,%c%V\ %P It's &...
D. Ben Knoble's user avatar
  • 26.6k
3 votes

How to temporarily change file encoding?

You can change the encoding of a loaded buffer simply by setting 'fileencoding' and then saving the file: :set fileencoding=utf-8 :w Hopefully this will allow your plugin to work, and then if ...
Rich's user avatar
  • 32.2k
3 votes
Accepted

Vim not encoding with UTF-8

I feel like an idiot. The test file doesn't have any non-ASCII characters in it, so there is nothing for file to look for that would tell it the encoding Vim is using. So I repeated the test with ä in ...
Nero gris's user avatar
  • 161
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

modelines not executed when opening new file in new tab

I think you might be misunderstanding how the 'fileformats' (plural) setting is used. This setting is a global list of file formats that Vim tries when opening any file in order to see which matches ...
Rich's user avatar
  • 32.2k
3 votes

UTF-8 not working on VIM

Windows doesn't use UTF-8 natively. It uses UTF-16LE by default. If you do not change the Windows console to UTF-8, it is not going to do what you want with the text. Part of the problem may be that ...
Warren Young's user avatar
3 votes
Accepted

Making Vim work with Unicode: what is the reason to use "setglobal fileencoding=utf-8"?

I think the recommendation for setting fileencoding instead of having it inherit from the encoding setting, is more or less to have it explicit that you are preferring UTF-8. In addition, since this ...
Christian Brabandt's user avatar
2 votes

gvim incorrect font (or encoding) in menu

Looks like there is no easy way to change font/encoding for menu rendering. Maybe it's somewhere in the code files, and you need to change and compile it in order to be able to decode menu in another ...
Vladimir Oprya's user avatar
2 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
2 votes

Can I fall back to latin1 if there are illegal bytes?

The biggest problem with your example is [noeol]. Note that the bytes 00 DF do not really make a file that a text editor expects; if you add a newline to the end (00 DF 0A), you definitely won't get ...
brhfl's user avatar
  • 294
2 votes
Accepted

Chinese characters become unrecognizable overnight in Neovim

Vim has 4 configurations related to encoding: encoding, fileencoding, fileencodings, and termencoding. Encoding is what vim uses internally, fileencodings sets the turn in which vim tries to figure ...
Ahacad's user avatar
  • 131
2 votes

How to get the encoded byte sequence for a character in the status line?

In addition to @D. Ben Knoble’s suggestion, you can capture the result of a normal mode command (g8 in this example) using :redir to store it in a variable: redir => char_bytes exec 'normal! g8' ...
Jake Grossman's user avatar
2 votes
Accepted

Vim's "ga" and utf-8 characters: What is <M-x>?

<M-x> is the notation for Altx on a PC or Optionx on a Mac. I understand that you would like to enter the ∩ ("cap") character easily, ideally using Altx. I doubt that it is possible. ...
Vivian De Smedt's user avatar
2 votes
Accepted

How to change the encoding of the text in the current buffer?

Vivian's answer covers the one-shot case. If you regularly handle files saved in an esoteric (read: non-western) encoding, it will help to tweak the fileencodings (note the trailing 's') option to ...
Friedrich's user avatar
  • 2,215
2 votes
Accepted

Can ++enc=utf-8 be made the default action for :w?

If the Vim file is a new file created within Vim (e.g. using :enew) the default encoding apply. You can set the default encoding of new buffer as utf-8 by adding the following line in your vimrc file: ...
Vivian De Smedt's user avatar
1 vote

How to copy and paste non English characters?

Finally I found the solution for this. It was because of the locale setting of my terminal, so I exported these variables in my .zshrc (maybe you can put it into .profile, if you're not using ZSH). ...
Lai32290's user avatar
  • 275
1 vote
Accepted

Why does backslash-escaping a CJK character cause a very-magic regex match to fail?

According to :h /\v: */\v* */\V* Use of "\v" means that after it, all ASCII characters except '0'-'9', 'a'-'z', 'A'-'Z' and '_' have special meaning: "very magic" It's ...
dedowsdi's user avatar
  • 6,268
1 vote

What is fileencoding of .vimrc?

As hinted at in the help files (:help scriptencoding), if you do not use scriptencoding, vim does no conversion, effectively assuming the script is in the encoding of the 'encoding' option. This is ...
Mass's user avatar
  • 14.2k

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