简体   繁体   English

为什么Vim在Ex模式下不能正确插入西里尔符号?

[英]Why vim doesn't insert cyrillic symbols properly in Ex mode?

To make changes in several files I use the following script: 要在几个文件中进行更改,我使用以下脚本:

echo search('publications.html"') | normal o<li><a href="./book_series.html">Книжные серии</a></li>
echo search('collections.html"') | d
echo search('photo.html"') | d
wq

Then I do for file in *.html do; vim -e $file < script; done 然后我for file in *.html do; vim -e $file < script; done for file in *.html do; vim -e $file < script; done

As a result a string "^Z=86=K5 A5@88" is inserted instead of "Книжные серии". 结果,插入了字符串“ ^ Z = 86 = K5 A5 @ 88”而不是“Книжныесерии”。 All html files as well as the script itself are utf-8 encoded, and no other problems with Cyrillic revealed. 所有的html文件以及脚本本身都是utf-8编码的,并且没有发现Cyrillic的其他问题。 What's going on? 这是怎么回事?

Thanks in advance for any comment! 预先感谢您的任何评论!

You probably need to tell Vim to interpret your script as utf-8, even if all the encodings are correct. 即使所有编码正确,您也可能需要告诉Vim将脚本解释为utf-8。

Try inserting this line at the top of your script: 尝试在脚本顶部插入以下行:

 scriptencoding utf-8

According to the vim_use mailing list response to this same question, multibyte characters are not handled in Vim's ex mode . 根据vim_use邮件列表对此问题的回答, 多字节字符在Vim的ex模式下不被处理

Thus, the solution is to not use ex mode at all. 因此,解决方案是根本不使用ex模式。

Instead of using: 而不是使用:

vim -e $file < script

Use the -S flag to run the script outside of ex mode: 使用-S标志在ex模式之外运行脚本:

vim -S script $file

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM