Skip to main content
added 187 characters in body
Source Link
saginaw
  • 6.9k
  • 2
  • 27
  • 47

I have the following code in my vimrc:

function! s:WordPos(dir) abort
    return a:dir ==# 'right'
    \ ? searchpos('\<', 'nz', line('.'))[1]
    \ : searchpos('\<', 'bn', line('.'))[1]
endfunction

silent! execute "set <M-b>=\eb"
silent! execute "set <M-f>=\ef"

inoremap <expr> <M-b> <SID>WordPos('left') == 0
\ ? '<S-Left>'
\ : repeat('<C-G>U<Left>', col('.') - <SID>WordPos('left'))

inoremap <expr> <M-f> <SID>WordPos('right') == 0
\ ? '<S-Right>'
\ : repeat('<C-G>U<Right>', <SID>WordPos('right') - col('.'))

The goal is to move by words in insert mode with Alt-b, Alt-f without breaking the undo sequence.

It works more or less but if I try to type the character â, instead of inserting it, Vim triggers the mapping for Alt-b, which makes the cursor move one word backward.

As soon as I comment the mapping for Alt-b, the problem disappears. It happens in Vim as well as in gVim.

The output of the shell command xxd -p when I hit Alt-b is 1b62, and for â it's c3a2.

Why does Vim interpret â as Alt-b even though the keycodes seem different?

I have the following code in my vimrc:

function! s:WordPos(dir) abort
    return a:dir ==# 'right'
    \ ? searchpos('\<', 'nz', line('.'))[1]
    \ : searchpos('\<', 'bn', line('.'))[1]
endfunction

silent! execute "set <M-b>=\eb"

inoremap <expr> <M-b> <SID>WordPos('left') == 0
\ ? '<S-Left>'
\ : repeat('<C-G>U<Left>', col('.') - <SID>WordPos('left'))

The goal is to move by words in insert mode with Alt-b, Alt-f without breaking the undo sequence.

It works more or less but if I try to type the character â, instead of inserting it, Vim triggers the mapping for Alt-b, which makes the cursor move one word backward.

As soon as I comment the mapping for Alt-b, the problem disappears. It happens in Vim as well as in gVim.

The output of the shell command xxd -p when I hit Alt-b is 1b62, and for â it's c3a2.

Why does Vim interpret â as Alt-b even though the keycodes seem different?

I have the following code in my vimrc:

function! s:WordPos(dir) abort
    return a:dir ==# 'right'
    \ ? searchpos('\<', 'nz', line('.'))[1]
    \ : searchpos('\<', 'bn', line('.'))[1]
endfunction

silent! execute "set <M-b>=\eb"
silent! execute "set <M-f>=\ef"

inoremap <expr> <M-b> <SID>WordPos('left') == 0
\ ? '<S-Left>'
\ : repeat('<C-G>U<Left>', col('.') - <SID>WordPos('left'))

inoremap <expr> <M-f> <SID>WordPos('right') == 0
\ ? '<S-Right>'
\ : repeat('<C-G>U<Right>', <SID>WordPos('right') - col('.'))

The goal is to move by words in insert mode with Alt-b, Alt-f without breaking the undo sequence.

It works more or less but if I try to type the character â, instead of inserting it, Vim triggers the mapping for Alt-b, which makes the cursor move one word backward.

As soon as I comment the mapping for Alt-b, the problem disappears. It happens in Vim as well as in gVim.

The output of the shell command xxd -p when I hit Alt-b is 1b62, and for â it's c3a2.

Why does Vim interpret â as Alt-b even though the keycodes seem different?

edited body; edited title
Source Link
saginaw
  • 6.9k
  • 2
  • 27
  • 47

Why does Vim interpret â as <MAlt-b>b in a mapping?

I have the following code in my vimrc:

function! s:WordPos(dir) abort
    return a:dir ==# 'right'
    \ ? searchpos('\<', 'nz', line('.'))[1]
    \ : searchpos('\<', 'bn', line('.'))[1]
endfunction

silent! execute "set <M-b>=\eb"

inoremap <expr> <M-b> <SID>WordPos('left') == 0
\ ? '<S-Left>'
\ : repeat('<C-G>U<Left>', col('.') - <SID>WordPos('left'))

The goal is to move by words in insert mode with <MAlt-b>b, <MAlt-f>f without breaking the undo sequence.

It works more or less but if I try to type the character â, instead of inserting it, Vim triggers the mapping for <MAlt-b>b, which makes the cursor move one word backward.

As soon as I comment the mapping for <MAlt-b>b, the problem disappears. It happens in Vim as well as in gVim.

The output of the shell command xxd -p when I hit <MAlt-b>b is 1b62, and for â it's c3a2.

Why does Vim interpret â as <MAlt-b>b even though the keycodes seem different?

Why does Vim interpret â as <M-b> in a mapping?

I have the following code in my vimrc:

function! s:WordPos(dir) abort
    return a:dir ==# 'right'
    \ ? searchpos('\<', 'nz', line('.'))[1]
    \ : searchpos('\<', 'bn', line('.'))[1]
endfunction

silent! execute "set <M-b>=\eb"

inoremap <expr> <M-b> <SID>WordPos('left') == 0
\ ? '<S-Left>'
\ : repeat('<C-G>U<Left>', col('.') - <SID>WordPos('left'))

The goal is to move by words in insert mode with <M-b>, <M-f> without breaking the undo sequence.

It works more or less but if I try to type the character â, instead of inserting it, Vim triggers the mapping for <M-b>, which makes the cursor move one word backward.

As soon as I comment the mapping for <M-b>, the problem disappears. It happens in Vim as well as in gVim.

The output of the shell command xxd -p when I hit <M-b> is 1b62, and for â it's c3a2.

Why does Vim interpret â as <M-b> even though the keycodes seem different?

Why does Vim interpret â as Alt-b in a mapping?

I have the following code in my vimrc:

function! s:WordPos(dir) abort
    return a:dir ==# 'right'
    \ ? searchpos('\<', 'nz', line('.'))[1]
    \ : searchpos('\<', 'bn', line('.'))[1]
endfunction

silent! execute "set <M-b>=\eb"

inoremap <expr> <M-b> <SID>WordPos('left') == 0
\ ? '<S-Left>'
\ : repeat('<C-G>U<Left>', col('.') - <SID>WordPos('left'))

The goal is to move by words in insert mode with Alt-b, Alt-f without breaking the undo sequence.

It works more or less but if I try to type the character â, instead of inserting it, Vim triggers the mapping for Alt-b, which makes the cursor move one word backward.

As soon as I comment the mapping for Alt-b, the problem disappears. It happens in Vim as well as in gVim.

The output of the shell command xxd -p when I hit Alt-b is 1b62, and for â it's c3a2.

Why does Vim interpret â as Alt-b even though the keycodes seem different?

added 32 characters in body
Source Link
saginaw
  • 6.9k
  • 2
  • 27
  • 47

I have the following code in my vimrc:

function! s:WordPos(dir) abort
    return a:dir ==# 'right'
    \ ? searchpos('\<', 'nz', line('.'))[1]
    \ : searchpos('\<', 'bn', line('.'))[1]
endfunction

silent! execute "set <M-b>=\eb"

inoremap <expr> <M-b> <SID>WordPos('left') == 0
\ ? '<S-Left>'
\ : repeat('<C-G>U<Left>', col('.') - <SID>WordPos('back''left'))

The goal is to move by words in insert mode with <M-b>, <M-f> without breaking the undo sequence.

It works more or less but if I try to type the character â, instead of inserting it, Vim triggers the mapping for <M-b>, which makes the cursor move one word backward.

As soon as I comment the mapping for <M-b>, the problem disappears. It happens in Vim as well as in gVim.

The output of the shell command xxd -p when I hit <M-b> is 1b62, and for â it's c3a2.

Why does Vim interpret â as <M-b> even though the keycodes seem different?

I have the following code in my vimrc:

function! s:WordPos(dir) abort
    return a:dir ==# 'right'
    \ ? searchpos('\<', 'nz', line('.'))[1]
    \ : searchpos('\<', 'bn', line('.'))[1]
endfunction

silent! execute "set <M-b>=\eb"

inoremap <expr> <M-b> <SID>WordPos('left') == 0
\ ? '<S-Left>'
\ : repeat('<C-G>U<Left>', col('.') - <SID>WordPos('back'))

The goal is to move by words in insert mode with <M-b>, <M-f> without breaking the undo sequence.

It works more or less but if I type the character â, Vim triggers the mapping for <M-b>.

As soon as I comment the mapping for <M-b>, the problem disappears. It happens in Vim as well as in gVim.

The output of the shell command xxd -p when I hit <M-b> is 1b62, and for â it's c3a2.

Why does Vim interpret â as <M-b> even though the keycodes seem different?

I have the following code in my vimrc:

function! s:WordPos(dir) abort
    return a:dir ==# 'right'
    \ ? searchpos('\<', 'nz', line('.'))[1]
    \ : searchpos('\<', 'bn', line('.'))[1]
endfunction

silent! execute "set <M-b>=\eb"

inoremap <expr> <M-b> <SID>WordPos('left') == 0
\ ? '<S-Left>'
\ : repeat('<C-G>U<Left>', col('.') - <SID>WordPos('left'))

The goal is to move by words in insert mode with <M-b>, <M-f> without breaking the undo sequence.

It works more or less but if I try to type the character â, instead of inserting it, Vim triggers the mapping for <M-b>, which makes the cursor move one word backward.

As soon as I comment the mapping for <M-b>, the problem disappears. It happens in Vim as well as in gVim.

The output of the shell command xxd -p when I hit <M-b> is 1b62, and for â it's c3a2.

Why does Vim interpret â as <M-b> even though the keycodes seem different?

Source Link
saginaw
  • 6.9k
  • 2
  • 27
  • 47
Loading