[英]How can I bind non-ascii keys with a utf-8-encoded .vimrc?
I have a Scandinavian keyboard, and I want to bind my Æ , Ø and Å keys . 我有一个斯堪的纳维亚键盘,我想绑定我的Æ , Ø和Å键 。 For example, I use Ø as leader : 例如, 我将Ø用作领导者 :
" ok, works:
let mapleader = "ø"
When the .vimrc
is encoded in latin1
, this works like a charm. 当.vimrc
用latin1
编码时,这就像一个latin1
。 However, I want to use :set enc=utf8
in my .vimrc
, and then the mappings stop working: 但是,我想在.vimrc
使用:set enc=utf8
,然后映射停止工作:
" whoops, doesn't work:
let mapleader = "ø"
set encoding=utf-8
I presume this is because the .vimrc
is written as utf-8, and that Vim is unable to parse or map the multi-byte characters. 我认为这是因为.vimrc
是用utf-8编写的,并且Vim无法解析或映射多字节字符。
What I want is to be able to use my non-ascii keymappings while still defaulting to utf-8 for all files other than .vimrc
. 我想要的是能够使用我的非ascii键盘映射,同时仍然对.vimrc
以外的所有其他文件默认使用utf-8。 (Storing .vimrc
as latin1
would be an acceptable solution, but I haven't figured out a way to do it.) (将.vimrc
存储为latin1
是可以接受的解决方案,但我还没有找到一种方法来实现。)
I have tried all kinds of things, and none of the following work: 我已经尝试过各种方法,但没有以下工作:
encoding
and/or fileencoding
for .vimrc
. 模式行该设置encoding
和/或fileencoding
为.vimrc
。 "\ø"
and similar values instead. 将键映射到"\ø"
和类似的值。 .vimrc
to force defaulting to latin1
. 将无效的utf-8序列放入.vimrc
以强制默认为latin1
。 encoding
and/or fileencoding
for .vimrc
. 各种自动命令来设置encoding
和/或fileencoding
为.vimrc
。 --cmd "set encoding=latin1"
, because I edit my .vimrc
too frequently for that to be feasible. 用--cmd "set encoding=latin1"
打开Vim,因为我编辑.vimrc
太频繁了,以至于不可行。 How can I use both set encoding=utf-8
and map my non-ascii keys? 如何同时使用 set encoding=utf-8
和映射我的非ascii键?
The problem is caused by the ultisnips plugin. 该问题是由ultisnips插件引起的。 Disabling ultisnips will resolve the issue. 禁用ultisnips将解决此问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.