VIM: deleting non-roman characters
I'm working with a document with both Roman and Asian characters, an开发者_JS百科d I want put them each of them alone in two separated files and keeps their original structure, is it possible?
Thanks
Might be easier in Python. Here's a script that reads a text file and creates two output files: one with low-ASCII and one with everything else. If you have Python support compiled in Vim, the following should also be usable from within Vim (with minimal changes).
import codecs
mixedInput = codecs.open('mixed.txt', 'r', 'utf-8')
lowAsciiOutput = codecs.open('lowAscii.txt', 'w', 'utf-8')
otherOutput = codecs.open('other.txt', 'w', 'utf-8')
for rawline in mixedInput:
line = rawline.rstrip()
for c in line:
if ord(c) < 2**7:
lowAsciiOutput.write(c)
else:
otherOutput.write(c)
otherOutput.write('\n')
lowAsciiOutput.write('\n')
mixedInput.close()
lowAsciiOutput.close()
otherOutput.close()
example input file (mixed.txt):
欢迎来到Mifos管理区域
Does that do what you want?
Also saved as a gist: https://gist.github.com/855545
精彩评论