Loading ...
Sorry, an error occurred while loading the content.

encoding=utf-8 and Alt-mappings

Expand Messages
  • Valery Kondakoff
    Hi! Can I ask you two questions, related to gVIM encoding settings? I m using gVIM 6.2 (WinXP Pro). There are my encoding-related _vimrc settings: set
    Message 1 of 4 , Oct 15, 2003
    • 0 Attachment
      Hi!

      Can I ask you two questions, related to gVIM encoding settings?

      I'm using gVIM 6.2 (WinXP Pro). There are my encoding-related _vimrc
      settings:

      set nocompatible
      set encoding=utf-8
      set fileencoding=cp1251
      set fileencodings=ucs-bom,utf-8,cp1251,latin1
      set guifont=courier_new:h11
      set keymap=russian-jcukenwin

      1) I'm trying to add some 'Alt-mappings' to my _vimrc. This is a
      simple example:

      nnoremap <A-o> :echo "test"<cr>

      This mapping works in current configuration. But if I change
      'encoding' to cp1251 (this is my Windows default encoding) all
      Alt-mappings stops to work.

      I can get it back to work if I change the settings like this:

      set encoding=cp1251
      set termencoding=utf-8

      Please, can anyone explain me what's the problem there? Why do I need
      to enable utf-8 in 'termencoding' to make Alt-mappings to work? Why
      Alt-mapping are not working, when 'termencoding' is set to cp1251?

      2) There is another one strange problem. When I execute 'nnoremap
      <A-o> :echo "test"<cr>' mapping with 'encoding' set to utf-8, the word
      'test' is printed in gVIM command line (last line of the window). This
      is exactly what I wanted.

      But when I execute the same mapping with 'encoding' set to cp1251 and
      'termencoding' set to 'utf-8', I'm receiving two lines in command
      window:

      :echo "test"
      test

      Why this happens? Why I'm receiving different output when different
      encoding/termencoding settings are used?

      Thank you.


      --
      Best regards,
      Valery Kondakoff mailto:strauss@...

      PGP key: mailto:pgp-public-keys@...?subject=GET%20strauss@...
    • Camillo Särs
      ... [...] termencoding was missing, and it should be set to your current code page. If you change encoding without having termencoding set, the results on
      Message 2 of 4 , Oct 17, 2003
      • 0 Attachment
        Valery Kondakoff wrote:
        > I'm using gVIM 6.2 (WinXP Pro). There are my encoding-related _vimrc
        > settings:
        [...]

        termencoding was missing, and it should be set to your current code page. If
        you change encoding without having termencoding set, the results on Window can
        be surprising.

        > I can get it back to work if I change the settings like this:
        >
        > set encoding=cp1251
        > set termencoding=utf-8

        I don't think that termencoding=utf-8 works as you would expect. You migh be
        seeing a result of setting the mapping when encoding was utf-8 as well.

        > But when I execute the same mapping with 'encoding' set to cp1251 and
        > 'termencoding' set to 'utf-8', I'm receiving two lines in command
        > window:
        >
        > :echo "test"
        > test
        >
        > Why this happens? Why I'm receiving different output when different
        > encoding/termencoding settings are used?

        Having termencoding set to something else than your own code page on Windows
        may produce extraordinarily strange results. Have you simply what happens if
        you do:

        set termencoding=cp1251
        set encoding=utf-8
        set fileencoding=cp1251
        ...

        and only *then* run the remapping?

        AFAIK, changing the encoding changes a lot of stuff internally in vim. You
        should set your desired encoding early and only then do stuff that might be
        dependent on the encoding.

        Camillo
        --
        Camillo Särs <+ged+@...> ** Aim for the impossible and you
        <http://www.iki.fi/+ged> ** will achieve the improbable.
        PGP public key available **
      • Valery Kondakoff
        Hello, Camillo! Friday, October 17, 2003, 2:24:58 PM, you wrote: CS set termencoding=cp1251 CS set encoding=utf-8 CS set fileencoding=cp1251 CS ... CS and
        Message 3 of 4 , Oct 17, 2003
        • 0 Attachment
          Hello, Camillo!

          Friday, October 17, 2003, 2:24:58 PM, you wrote:


          CS> set termencoding=cp1251
          CS> set encoding=utf-8
          CS> set fileencoding=cp1251
          CS> ...

          CS> and only *then* run the remapping?

          Here are the results (WinXP Pro, gVim 6.2 1-121):

          1)
          set termencoding=cp1251
          set encoding=utf-8
          set fileencoding=cp1251
          nnoremap <A-o> :echo "test"<cr>

          Mapping does not work at all.

          2)
          set termencoding=utf-8
          set encoding=utf-8
          set fileencoding=cp1251
          nnoremap <A-o> :echo "test"<cr>

          Mapping works as expected: 'test' is printed on command line.

          3)
          set termencoding=cp1251
          set encoding=cp1251
          set fileencoding=cp1251
          nnoremap <A-o> :echo "test"<cr>

          Mapping works as expected: 'test' is printed on command line.

          4)
          set termencoding=utf-8
          set encoding=cp1251
          set fileencoding=cp1251
          nnoremap <A-o> :echo "test"<cr>

          Mapping is working, but

          :echo "test"
          test

          is printed on command line.

          --
          Best regards,
          Valery mailto:strauss@...

          PGP key: mailto:pgp-public-keys@...?subject=GET%20strauss@...

          np: Placebo - The Crawl (Without You I'm Nothing)
        • Tony Mechelynck
          ... Weird. On my W98 system (gvim 6.2.98) I just tested, on an already-open gvim where encoding=utf-8 termencoding=latin1 the command noremap :echo
          Message 4 of 4 , Oct 17, 2003
          • 0 Attachment
            Valery Kondakoff <strauss@...> wrote:
            > Hello, Camillo!
            >
            > Friday, October 17, 2003, 2:24:58 PM, you wrote:
            >
            >
            > > set termencoding=cp1251
            > > set encoding=utf-8
            > > set fileencoding=cp1251
            > > ...
            >
            > > and only *then* run the remapping?
            >
            > Here are the results (WinXP Pro, gVim 6.2 1-121):
            >
            > 1)
            > set termencoding=cp1251
            > set encoding=utf-8
            > set fileencoding=cp1251
            > nnoremap <A-o> :echo "test"<cr>
            >
            > Mapping does not work at all.
            >
            > 2)
            > set termencoding=utf-8
            > set encoding=utf-8
            > set fileencoding=cp1251
            > nnoremap <A-o> :echo "test"<cr>
            >
            > Mapping works as expected: 'test' is printed on command line.
            >
            > 3)
            > set termencoding=cp1251
            > set encoding=cp1251
            > set fileencoding=cp1251
            > nnoremap <A-o> :echo "test"<cr>
            >
            > Mapping works as expected: 'test' is printed on command line.
            >
            > 4)
            > set termencoding=utf-8
            > set encoding=cp1251
            > set fileencoding=cp1251
            > nnoremap <A-o> :echo "test"<cr>
            >
            > Mapping is working, but
            >
            > > echo "test"
            > test
            >
            > is printed on command line.
            >
            > --
            > Best regards,
            > Valery mailto:strauss@...
            >
            > PGP key:
            > mailto:pgp-public-keys@...?subject=GET%20strauss@...
            >
            > np: Placebo - The Crawl (Without You I'm Nothing)

            Weird. On my W98 system (gvim 6.2.98) I just tested, on an already-open gvim
            where

            encoding=utf-8
            termencoding=latin1

            the command

            noremap <M-o> :echo "test"

            Since I didn't map a <CR>, the cursor is left on the command-line, preceded
            by :echo "test" . I regard this as normal behaviour. But note that it works
            only with the "normal" Alt-key (left of the spacebar), not with the key
            labeled "AltGr" (right of the spacebar). Using either :redir to a register,
            :map then p, or Ctrl-V followed by Alt-o, shows that Alt-o is represented in
            both cases by the key: decimal 239, hex EF, octal 357.

            Maybe you should try pressing Ctrl-V followed by Alt-o as the {lhs} of your
            mapping? (And replace Ctrl-V by Ctrl-Q if your Ctrl-V does a paste.)

            Regards,
            Tony.
          Your message has been successfully submitted and would be delivered to recipients shortly.