45

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\ %B Gives you: 8984 2318 Another way is to use ga or the :ascii command. From :help ga: :as[cii] or ga :as :ascii ga ...


7

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' , '♥'], \ ['04' , '♦'], \ ['05' , '♣'], \ ['06' , '♣'], \ ['07' , '•'], \ ['08' , '◘'], \ ['^A' , '¢'], \ ] for [value, ...


5

It is whatever you define whit :scriptencoding. it should be the first line in you .vimrc file, e.g.: scriptencoding utf-8 set number set ... Be aware that some options (listchars for example) only accept single width values. Edit: Yeah, Vim is weird. encoding is for the editor itself, fileencoding is for the buffer and scriptencoding is for Vim scripts.


5

Vim's name for that encoding is ucs-2le (ucs-2 for Unicode, 2 byte per character, le for little endian). You can open that via :edit ++enc=ucs-2le filename enforcing the encoding, or alternatively (if you open such files often), add that encoding to the list of detected ones: :set fileencodings^=ucs-2le


4

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 used to force the value of 'fileformat', 'fileencoding' or 'binary' to a value for one command, and to specify the behavior for bad characters. The form is: > ...


4

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 command: function! s:toggle_unicode(line1, line2) abort if search('\\u\x\+', 'n') execute a:line1.','.a:line2.'s/\%(\\u\x\+\)\+/\=eval(''"''.submatch(0).''"'')/...


4

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 Unicode character U+2018 LEFT SINGLE QUOTATION MARK. Asc and Chr are old, pre-Unicode functions, which is why they are reporting the Windows-1252 character codes. If ...


4

The question 20.5 of the Vim FAQ seems to indicate that vim will receive a single character: 20.5. Why does mapping the <C-...> key not work? The only Ctrl-printable-key chords which Vim can reliably detect (because they are defined in the ASCII standard) are the following: > Ctrl-@ 0x00 NUL Ctrl-A to ...


4

The edit ++enc=ucs-2le [filename] only applies to the current file; when multiple are passed on the command-line, that's the last opened one. You could open the other with :diffsplit ++enc=ucs-2le file2, but in this case, it's shorter to augment the 'fileencodings' option: vim --cmd "set fileencodings^=ucs-2le" -d icacls.txt icacls2.txt This allows you to ...


4

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 (e.g. the 'fileformat') option does not matter. In a replace command however, the \r in the replace part will always produce an actual new line, since the \n ...


3

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 you aren't using Windows console, at least not directly: your screenshot shows you're using a third-party tool called Cmder, which may be part of the problem. ...


3

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 it and it returns "utf-8" as desired. In short, file was doing its best, and Vim was doing what I wanted it to do.


3

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 default 'encoding' to UTF-8. It defaults to latin1, but will change based on the locale of your environment. However, since changing 'encoding' at runtime is ...


3

There's nothing built-in, but the following mapping seems to do the trick. " g9 Print the hex values of the bytes used in the " character under the cursor / selected text, using the " actual 'fileencoding' of the buffer. function! s:ShowHexFileEncodingCharacter( isSelection ) let l:text = (a:isSelection ...


3

^Z is a control character more or less synonymous with EOF (end of file). Maybe they were mandatory for the compiler used by the author? If you have that line in every file in the project: :argadd **/* :argdo g/<C-v><C-z>/d <C-v><C-z> is Ctrl+V followed by Ctrl+Z, it should insert ^Z and make the command look like: :argdo g/^Z/d


3

Those characters are actually color encoding. Don't you think it odd that when you type more you get color instead of black-and-white characters? You must have grep set as an alias to grep --color=always. You're probably going to want to make a separate grep alias for viewing results in the console versus extracting text from files. Basically, vim is being ...


2

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 encoding. I have the same issue (in Russian localization), I think it appears after adding in vimrc this: set termencoding=utf-8 set encoding=utf-8 set ...


2

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, nmap PpP :ha<CR> (:ha = :hardcopy). Using :ha, Neovim was not printing Greek letters, ... even though my (Arch Linux) locale was LANG=en_US.UTF-8 ... ...


2

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 the [noeol] error, and I suspect that the file will now correctly open as latin1 (it does in my tests), and you'll see something like <00>ý or ^@ý. I'm not ...


2

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 _vimrc file (Windows equivalent of Linux .vimrc file). You can open your _vimrc file with command: :e $MYVIMRC :set encoding=utf-8 Bellow is actual setting ...


2

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>


2

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 very often utf-8, occasionally latin1. Other encodings are possible. Generally you want to use scriptencoding utf-8 when your script file contains non-ascii ...


1

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 ASCII characters, not any characters. According to :h /\: */\* */\\* \x A backslash followed by a single character, with no special ...


1

From :help 'encoding': NOTE: Changing this option will not change the encoding of the existing text in Vim. It may cause non-ASCII text to become invalid. It should normally be kept at its default value, or set when Vim starts up. See multibyte. To reload the menus see :menutrans. So either set it at the first line, or don't set it at all.


1

This should solve part of the problem. Try printf 'a\xC0b'| vim - --cmd "set fencs=utf8" -c "set fenc=utf8" It reads the file as utf-8 as you wanted, but the ++bad=keep thing is not included.


1

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 browser I get this (with color scheme!): I have this in my .vimrc, which deletes the new html buffer and stored file: nnoremap <F2> <ESC> :TOhtml &...


1

It can depend on your system. Some characters may be right on one system and not work at all on another. Between Macintosh, Windows, and Unix/Linux, there are three different types of carriage returns. \n may work for you. You could also try them both together: \n\r (I think that's the right way, but you could also try it reversed) Alternately, you can ...


1

Actually, the decision was to update gVim to 8.0 version, released just a few weeks ago. Then such settings were useful as well: set encoding=utf8 set termencoding=utf8 set guifont=Consolas:h11:cRUSSIAN "to get proper font for Cyrillic set fileencodings=utf8,cp1251,cp866,koi8r "to get English menu instead of broken Russian set langmenu=en_US ...


1

Though Cygwin is installed in Windows, it resembles linux. So, setting the fileformat to unix solves the problem. :set fileformat=unix Now, the unicode characters are accepted by Cygwin.


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