英文:
how can I save and open file with non-printing char correctly by vim?
问题
我将一组移动操作存储到我的寄存器 q
中。
移动操作如下:
我想将它保存到文件中以便将来使用。
但是当我再次打开那个文件时,它的内容变成了
我无法正确保存这些不可打印字符到文件中吗?我应该怎么做?
我已经尝试过更改设置,如编码、文件编码、文件编码设置、终端编码、可打印字符等,但都没有用。
英文:
I make a set of move into my register q
.
the move like:
and I want to save it in a file so that I can use it in the future.
But when I open that file again,its contents become
Can't I save these non-printing char in a file correctly? What should I do for this?
I have changed set such as encoding,fileencoding,fileencodings,termencoding,isprint,doesn't work at all
答案1
得分: 1
这些字符是Vim在录制期间处理按键时产生的无用痕迹。它们毫无意义,所以在粘贴之前可以放心地将它们删除。
例如,这些是我在寄存器 q
中录制的随机按键:
bi-<Esc>ea-<Esc>
而这是寄存器 q
中的内容(^[
是一个Esc的文字表示,而不是^
后跟[
):
bi-^[<80><fd>aea-^[<80><fd>a
这些东西只是毫无用处的垃圾,本来就不应该存在:
bi-^[<80><fd>aea-^[<80><fd>a
^^^^^^^^^ ^^^^^^^^^
事实上,它们甚至在Vim中都没有被用于任何用途,因此您可以——而且应该——在将寄存器内容转储到另一个缓冲区之后,在将其写入磁盘之前手动删除它们:
bi-^[ea-^[
英文:
Those characters are useless artifacts of how Vim handles keystrokes during recording. They serve no purpose whatsoever so you can safely get rid of them before you paste.
For example, these are the random keystrokes I recorded in register q
:
bi-<Esc>ea-<Esc>
and this the content of register q
(^[
is a literal Esc, not ^
followed by [
):
bi-^[<80><fd>aea-^[<80><fd>a
These things are just useless garbage that shouldn't be there in the first place:
bi-^[<80><fd>aea-^[<80><fd>a
^^^^^^^^^ ^^^^^^^^^
In fact, they are not even used by Vim for anything, so you can—and should—remove them manually after you dump the register in another buffer, before you write it to disk:
bi-^[ea-^[
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论