Input using meta key under different encoding

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

Input using meta key under different encoding

Dave Roberts
I'm sure this is just how it is instead of being a bug but I didn't find
what I was looking for in the help files so...

Way back when, I used Brief as my only text editor (DOS/Windows) and
that meant heavy use of the Alt key. When I switched to VIM I gradually
replaced all my Alt key habits with <leader> whatever so I could switch
to terminals as necessary and continue to work. The one set of keys I
still use all the time is Alt-n and Alt-p for next and previous buffers.

I also sometimes edit old C programs that had "ASCII graphics" in the
comments to create boxes etc. The default encoding of "latin1" doesn't
show those correctly so I created a map to toggle between an encoding of
"latin1" and "8bit-cp437". After a while I decided to default to cp437
since everything else looked OK but then I noticed that Alt-n and Alt-p
stopped working.

I find that if I'm in "latin1" and (in insert mode) type ctrl-v alt-n to
insert the character then get get out of insert mode and put the cursor
on the character and use "ga" to see what it is I get <M-n> but if I do
the same thing when the encoding is "cp437" I get <M-^L>.

As I said, this is probably just how it is but I figured I'd ask...

Thanks,

- Dave
Reply | Threaded
Open this post in threaded view
|

Re: Input using meta key under different encoding

iler.ml
On 4/25/06, Dave Roberts <[hidden email]> wrote:
> I find that if I'm in "latin1" and (in insert mode) type ctrl-v alt-n to
> insert the character then get get out of insert mode and put the cursor
> on the character and use "ga" to see what it is I get <M-n> but if I do
> the same thing when the encoding is "cp437" I get <M-^L>.

For me, the sequence i ctrl-v alt-n <Left> <C-O>  ga results
in exactly same thing:
    <î>  <|n>  <M-n>  238,  Hex ee,  Octal 356
This is vim7.0f
I used command :set encoding=8bit-cp437 to change encoding.

Some useful info is missinf in your email.

1. Do you toggle some other settings besides 'encoding' when
you switch between the two encodings ? What is exact sequence of
commands that you use to switch encodings ?

2. What is your vim version, and OS ? Console vim or gui vim ?

Yakov
Reply | Threaded
Open this post in threaded view
|

Re: Input using meta key under different encoding

Dave Roberts
Yakov Lerner wrote:

> On 4/25/06, Dave Roberts <[hidden email]> wrote:
>  
>> I find that if I'm in "latin1" and (in insert mode) type ctrl-v alt-n to
>> insert the character then get get out of insert mode and put the cursor
>> on the character and use "ga" to see what it is I get <M-n> but if I do
>> the same thing when the encoding is "cp437" I get <M-^L>.
>>    
>
> For me, the sequence i ctrl-v alt-n <Left> <C-O>  ga results
> in exactly same thing:
>     <î>  <|n>  <M-n>  238,  Hex ee,  Octal 356
> This is vim7.0f
> I used command :set encoding=8bit-cp437 to change encoding.
>
> Some useful info is missinf in your email.
>
> 1. Do you toggle some other settings besides 'encoding' when
> you switch between the two encodings ? What is exact sequence of
> commands that you use to switch encodings ?
>
> 2. What is your vim version, and OS ? Console vim or gui vim ?
>
> Yakov
>
>  

WinXP, GVIM 7.0f.

Perform the following steps:

1. GVIM -u NONE -U NONE<cr>
2.:set nocompatible<cr>
3. Cut and past the following to the command line (all one line)

nmap <silent> <S-F5>     :if exists("g:save_encoding") \| exe "set
encoding=" . g:save_encoding \| unlet g:save_encoding \| else \| let
g:save_encoding=&encoding \| set encoding=8bit-cp437 \| endif<CR>:echo
&encoding<CR>

4. Enter the following key sequence from normal mode (I'm using "Alt-"
instead of "M-" in the keystrokes) (obviously everything between '<' and
'>' is a key or key-combination - not a literal less than or greater than):

i<C-v><Alt-n><CR><ESC><S-F5>i<C-v><Alt-n><ESC>

5. Use k to go up to the first line and ga shows the character is <M-n>

6. Use j to go to the second line and ga shows the character is <M-^L>

That's what I get anyway...

Note: My default is latin1 (not using $LANG). When I press S-F5 the
command line toggles between "cp437" and "latin1".

Thanks,

- Dave
Reply | Threaded
Open this post in threaded view
|

Re: Input using meta key under different encoding

iler.ml
On 4/26/06, Dave Roberts <[hidden email]> wrote:

> Yakov Lerner wrote:
> > On 4/25/06, Dave Roberts <[hidden email]> wrote:
> >
> >> I find that if I'm in "latin1" and (in insert mode) type ctrl-v alt-n to
> >> insert the character then get get out of insert mode and put the cursor
> >> on the character and use "ga" to see what it is I get <M-n> but if I do
> >> the same thing when the encoding is "cp437" I get <M-^L>.
> >>
> >
> > For me, the sequence i ctrl-v alt-n <Left> <C-O>  ga results
> > in exactly same thing:
> >     <î>  <|n>  <M-n>  238,  Hex ee,  Octal 356
> > This is vim7.0f
> > I used command :set encoding=8bit-cp437 to change encoding.
> >
> > Some useful info is missinf in your email.
> >
> > 1. Do you toggle some other settings besides 'encoding' when
> > you switch between the two encodings ? What is exact sequence of
> > commands that you use to switch encodings ?
> >
> > 2. What is your vim version, and OS ? Console vim or gui vim ?
> >
> > Yakov
> >
> >
>
> WinXP, GVIM 7.0f.
>
> Perform the following steps:
>
> 1. GVIM -u NONE -U NONE<cr>
> 2.:set nocompatible<cr>
> 3. Cut and past the following to the command line (all one line)
>
> nmap <silent> <S-F5>     :if exists("g:save_encoding") \| exe "set
> encoding=" . g:save_encoding \| unlet g:save_encoding \| else \| let
> g:save_encoding=&encoding \| set encoding=8bit-cp437 \| endif<CR>:echo
> &encoding<CR>
>
> 4. Enter the following key sequence from normal mode (I'm using "Alt-"
> instead of "M-" in the keystrokes) (obviously everything between '<' and
> '>' is a key or key-combination - not a literal less than or greater than):
>
> i<C-v><Alt-n><CR><ESC><S-F5>i<C-v><Alt-n><ESC>
>
> 5. Use k to go up to the first line and ga shows the character is <M-n>
>
> 6. Use j to go to the second line and ga shows the character is <M-^L>
>
> That's what I get anyway...
>
> Note: My default is latin1 (not using $LANG). When I press S-F5 the
> command line toggles between "cp437" and "latin1".

I confirm it. Alt-N is interpreted differently by vim depending
on 'set encoding'.  I'd like to test it on Linux gvim but at the moment,
I can't.

Yakov