Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multibyte character in rhs of mapping absent from output of ":map" #6071

Open
lacygoill opened this issue May 12, 2020 · 2 comments
Open

multibyte character in rhs of mapping absent from output of ":map" #6071

lacygoill opened this issue May 12, 2020 · 2 comments

Comments

@lacygoill
Copy link

Describe the bug

The output of :map x may be wrong when the rhs of the x mapping contains a multibyte character.

To Reproduce

Run this shell command:

vim -Nu NONE +'map x –'

Then, run this Ex command:

:map x

The output is:

x

Expected behavior

The output is:

x             –

Environment

  • Vim version: 8.2 Included patches: 1-740
  • OS: Ubuntu 16.04.6 LTS
  • Terminal: XTerm(322)

Additional context

With execute() (or :redir), the output is different (but still wrong):

vim -Nu NONE +'map x –'
:echo execute('map x')
x             ^S
              ^^

This time, Vim prints the caret notation of the C-s character.


I can reproduce the issue with an abbreviation too:

vim -Nu NONE +'iab x –'
:iab x
i  x

vim -Nu NONE +'iab x –'
:echo execute('iab x')
i  x             ^S
@tonymec
Copy link

tonymec commented May 12, 2020

Here are a few possibilities:

  • Does it work in gvim?
  • Are you able to display the same Unicode character in the same xterm when Vim is not running?
  • What is 'encoding' set to? In particular, is it set to utf-8 ? And if it is, does your vimrc set that value before defining the mapping?
  • If you define that mapping in your vimrc, does that vimrc include near the top the line
scriptencoding utf-8

?

  • In the shell from which you start Vim, what are $LC_ALL, $LC_CTYPE and $LANG set to (and which of them are unset)?

@lacygoill
Copy link
Author

Does it work in gvim?

No, it doesn't work as expected:

gvim -Nu NONE +'map x –'
:map x
x    ?
:echo execute('map x')
x    ^S

Are you able to display the same Unicode character in the same xterm when Vim is not running?

Yes:

$ printf -- '–'
–

What is 'encoding' set to? In particular, is it set to utf-8 ? And if it is, does your vimrc set that value before defining the mapping?

'encoding' is set with its default value which is utf-8.
I don't know when Vim sets the option, but I don't set it manually when I start Vim with -Nu NONE.
I can reproduce even if I run map x – later:

vim -Nu NONE
:map x –
:map x
x
:echo execute('map x')
x             ^S

If you define that mapping in your vimrc, does that vimrc include near the top the line

scriptencoding utf-8

No, but I have this line in my vimrc before installing mappings:

set encoding=utf-8

But I can reproduce even without any config.

In the shell from which you start Vim, what are $LC_ALL, $LC_CTYPE and $LANG set to (and which of them are unset)?

LC_ALL and LANG are both set to en_US.UTF-8. LC_CTYPE is unset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants