The content on your source web page was overzealously reformatted. The text was undoubtedly supposed to use (straight) single quotes (ASCII 39/0x27
, U+0027
) instead of curly single quotes (U+2018
and U+2019
, which are 0x91 and 0x92
in CP1252 (also known as MS-ANSI and WINDOWS-1252; a common 8-bit encoding on Windows)).
Vim is showing you the hex codes because they are not valid in whatever encoding Vim is using (probably UTF-8). If you are editing text that has already been saved in a file, then you can reload the file as CP1252 with :e ++enc=cp1252
; this should make the curly quotes visible. But there is no real reason to reload it as CP1252, just delete the 0x91
and 0x92
characters and replace them with single quotes.
@ChrisJohnsen, Is there any way to call vi with a flag that accomplishes the same thing as
:e ++enc=cp1252
? If I want to vi from the command line a file containing MS word characters, it would be nice to be able to do it in one step, rather than opening vi and then loading the file with the:e
command – Leo Simon – 2016-07-11T00:17:33.297@LeoSimon:
vim --cmd 'set fileencodings=cp1252' /path/to/file
— The command runs before the normal.vimrc
and sets thefileencodings
option (note the endings
; you can also use the shorter namefencs
) so that Vim will only try CP1252 when loading files. This should work for one-off editing of such files, but it may cause complications if you want to use that instance of Vim to edit files with other encodings. – Chris Johnsen – 2016-07-11T05:40:16.277Thanks!, to be explicit, I'm now using
vim -c"set fencs" /path/to/file
– Leo Simon – 2016-07-11T19:17:54.067You often get the curly quotes/apostrophe from content copied from MS Word which auto inserts the curly quotes/apostrophe as part of the "Smart Quotes" feature. If your font does not support those characters, you will just get an empty space instead of the character. – lambacck – 2010-12-21T15:31:04.043
1+1 for
:e ++enc=cp1252
– wfaulk – 2012-11-30T02:27:37.343