Domanda

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!

È stato utile?

Soluzione

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

Altri suggerimenti

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
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top