opened
BohrShaw
username_0
- `nvim --version`:
- Vim (version: ) behaves differently?
- Operating system/version:
- Terminal name/version:
- `$TERM`:

### Actual behaviour

### Expected behaviour

### Steps to reproduce using `nvim -u NORC`

```
nvim -u NORC

```
Meta/Alt key chords not recognized by function "char2nr
issue
created
justinmk
username_1
`getchar()` followed by `<M-[>` doesn't return a result that would be comparable to `char2nr("\<M-[>")`, even in Vim. So what would be the purpose of this? 

Of course, in Nvim `<M-[>` is not a single character, it's a modifier + character. But if there were a purpose then we could add compatibility to `char2nr()`.
comment
created
ZyX-I
username_2
Things like `echo char2nr("\<M-a>")` => 225 is hardly a good thing to keep. Remove `char2nr` you will see that all `"\<M-a>"` expands to is just “á” and nothing else. Or, in other words, *vim is unable to distinguish alt + a and actual a with acute accent*. I am far from liking this behaviour, even though I do not normally type that character: there were many cases when I typed `<Esc>a` and got “á” inserted instead of Vim doing what I needed.

@username_1 I would not really suggest to ever fix that. Turning `<M-x>` into x+128 is the last thing I want Neovim to do. I do not see any valid reason for current Vim behaviour: even though there were (and are if you configure that) terminals that used to set 8’th bit for meta, it does not look like a good reason to have *internal representation* do the same thing and not what Neovim is currently doing.
comment
created
justinmk
username_1
@username_2 What do you think it should return? Should we add a special constant to chords for `char2nr()` and `getchar()`? Or should nothing change, and we can close this?
comment
created
ZyX-I
username_2
I am fine with the current behaviour: based on what I know it is basically `a` preceded with usual internal representation of meta modifier, which is consistent with other keys with modifiers. The only use-case for keeping old behaviour I know is compatibility, but actually it is pretty easy to write code which works both on Vim and Neovim: just do

```VimL
let char = getchar()
if type(char) == type(0) | let char = nr2char(char) | endif
if char is# "\<M-a>"
  …
endif
```

It is normally a good idea to write code like that always: first convert `getchar()` output to string and only then do any checks. Though documentation does not suggest doing so.
comment
closed
justinmk
username_1
issue