Character encoding in vim

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Character encoding in vim

Ven Tadipatri
It looks like the directional quotes aren't being rendered correctly
in my vim editor. They show up as ~@~Y and ~@~X. How do I change this
so they show up properly? Also I set up a shortcut (Ctrl+L) to get rid
of all the ^M file endings, but it would be nice if they showed up
correctly as well.

Thanks,
Ven

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: Character encoding in vim

Jean-Rene David-2
* Ven Tadipatri [2011.05.18 16:30]:
> It looks like the directional quotes aren't being rendered correctly
> in my vim editor. They show up as ~@~Y and ~@~X. How do I change this
> so they show up properly?

This usually happens when 'encoding' or 'fileencoding' don't match the
content of the file. What are they set to when you edit that file?

> Also I set up a shortcut (Ctrl+L) to get rid of all the ^M file
> endings, but it would be nice if they showed up correctly as well.

^M's show up only when the file is malformed (i.e. it contains both unix
end-of-lines and DOS end-of-lines) so vim can't decide which format to
choose for the file. If the file is homogenous with respect to line
endings, then you won't see them.

--
JR

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: Character encoding in vim

Benjamin Fritz


On May 18, 4:43 pm, Jean-Rene David <[hidden email]> wrote:

> This usually happens when 'encoding' or 'fileencoding' don't match the
> content of the file. What are they set to when you edit that file?
>
> > Also I set up a shortcut (Ctrl+L) to get rid of all the ^M file
> > endings, but it would be nice if they showed up correctly as well.
>
> ^M's show up only when the file is malformed (i.e. it contains both unix
> end-of-lines and DOS end-of-lines) so vim can't decide which format to
> choose for the file. If the file is homogenous with respect to line
> endings, then you won't see them.
>

Or, they can show up when 'fileformats' does not contain "dos".
See :help 'fileformats', :help 'fileformat', and http://vim.wikia.com/wiki/File_format

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: Character encoding in vim

Benjamin Fritz
In reply to this post by Jean-Rene David-2


On May 18, 4:43 pm, Jean-Rene David <[hidden email]> wrote:
> * Ven Tadipatri [2011.05.18 16:30]:
>
> > It looks like the directional quotes aren't being rendered correctly
> > in my vim editor. They show up as ~@~Y and ~@~X. How do I change this
> > so they show up properly?
>
> This usually happens when 'encoding' or 'fileencoding' don't match the
> content of the file. What are they set to when you edit that file?
>

Since there are two bytes being displayed I'm going to guess you're
editing a UTF-8 encoded file with your encoding set to the default 8-
bit encoding for your system (probably latin1).

You will need to set at least two options to let this work correctly:

'encoding'
'fileencodings'

See the help for each, and also our current featured tip on the wiki,
http://vim.wikia.com/wiki/Working_with_Unicode

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: Character encoding in vim

Ven Tadipatri
On Thu, May 19, 2011 at 7:44 AM, Ben Fritz <[hidden email]> wrote:
>
>
>
> Since there are two bytes being displayed I'm going to guess you're
> editing a UTF-8 encoded file with your encoding set to the default 8-
> bit encoding for your system (probably latin1).

I'm actually editing the output of running maven, so maybe it wrote it
out in UTF-8 format.

>
> You will need to set at least two options to let this work correctly:
>
> 'encoding'
> 'fileencodings'
>

When I type :set encoding? it says  "option not supported". Maybe my
version of Vim wasn't built with unicode support?
How do I check if I have multi-byte support? Is there some easy way to
add it if it's not there, or do I have to rebuild vim?

Thanks,
Ven

> See the help for each, and also our current featured tip on the wiki,
> http://vim.wikia.com/wiki/Working_with_Unicode
>
> --

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: Character encoding in vim

Tony Mechelynck
On 24/05/11 22:51, Ven Tadipatri wrote:

> On Thu, May 19, 2011 at 7:44 AM, Ben Fritz<[hidden email]>  wrote:
>>
>>
>>
>> Since there are two bytes being displayed I'm going to guess you're
>> editing a UTF-8 encoded file with your encoding set to the default 8-
>> bit encoding for your system (probably latin1).
>
> I'm actually editing the output of running maven, so maybe it wrote it
> out in UTF-8 format.
>
>>
>> You will need to set at least two options to let this work correctly:
>>
>> 'encoding'
>> 'fileencodings'
>>
>
> When I type :set encoding? it says  "option not supported". Maybe my
> version of Vim wasn't built with unicode support?

If you get that, the probable reason is indeed that you have no
miltibyte support.

> How do I check if I have multi-byte support? Is there some easy way to
> add it if it's not there, or do I have to rebuild vim?

        :echo has('multi_byte')

zero means No, anything else (usually 1) means Yes

Also, in the output of ":version", you'll see -multi_byte if you don't
have it, +multi_byte or +multi_byte_ime or +multi_byte_ime/dyn if you do.

Now how to get a Vim executable with multibyte support? That depends on
your OS.

For Windows, browse to http://sourceforge.net/projects/cream/files/ and
get the latest installer under "Vim", it's a recent distribution with
console and GUI Vim, all runtime files updated to the date the installer
was built, and the corresponding "Release notes" are the output of the
:version command from the GUI, with a few additional blank lines for
legibility.

On most Linux distributions, there are several Vim packages that you can
install. How they are named depends on your distribution: for instance,
with my openSUSE Linux you should install the packages vim-base and
vim-data plus at least one of vim, vim-enhanced and gvim; a number of
optional plugins are also available. In general, if (like here) three
executables are provided, they are usually a "tiny" bare-bones version
with no expression evaluation and no syntax highlighting, a console
version with mostly everything except X11 support and GUI, and a
full-fledged GUI which can also work in Console mode.

You can also compile your own Vim, see
   http://vim.wikia.com/wiki/Category:Building_Vim
   http://vim.wikia.com/wiki/Getting_the_Vim_source_with_Mercurial
   http://users.skynet.be/antoine.mechelynck/vim/compunix.htm

On the Mac, I recommend the macvim distribution; see
http://vim.sourceforge.net/download.php#mac

>
> Thanks,
> Ven


HTH,
Tony.
--
Q:  How many supply-siders does it take to change a light bulb?
A:  None.  The darkness will cause the light bulb to change by itself.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php