문제

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

As a result a string "^Z=86=K5 A5@88" is inserted instead of "Книжные серии". All html files as well as the script itself are utf-8 encoded, and no other problems with Cyrillic revealed. What's going on?

Thanks in advance for any comment!

도움이 되었습니까?

해결책

According to the vim_use mailing list response to this same question, multibyte characters are not handled in Vim's ex mode.

Thus, the solution is to not use ex mode at all.

Instead of using:

vim -e $file < script

Use the -S flag to run the script outside of ex mode:

vim -S script $file

다른 팁

You probably need to tell Vim to interpret your script as utf-8, even if all the encodings are correct.

Try inserting this line at the top of your script:

 scriptencoding utf-8
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top