Why is
a newline for Vim?
从问题如何在vim中替换换行符开始?。在为换行符替换文本时,必须使用
,如下所示
1 2 | :%s/%/ /g |
但是,当替换字符的行尾和换行符时,可以这样做:
1 2 | :%s/ /%/g |
手册的哪个部分记录了这些行为,它们背后的原因是什么?
从http:/ / / / vim.wikia.com维基搜索:_ _ replace布尔P></
When Searching
...
is newline,
is
CR (carriage return =Ctrl-M =^M )When Replacing
...
is newline,
is a null byte (
0x00 ).
模式八:从在线文档P></
matches
matches an end-of-line -
When matching in a string instead of
buffer text a literal newline
character is matched.
另一个层面
- 我知道你不能使用
\0 to均值NULL ,知道你使用
- 我知道你不能使用
to均值
,知道你使用。
- 我知道你不能使用
to
均值,但我不知道谁会想要的字符的文件,在线的目的。
-?P></
Technical detail:
characters in the file are stored as in memory. In the display
they are shown as"^@ ". The translation is done when reading and writing
files. To match awith a search pattern you can just enter CTRL-@ or
"CTRL-V 000". This is probably just what you expect. Internally the
character is replaced with ain the search pattern. What is unusual is
that typing CTRL-V CTRL-J also inserts a, thus also searches for a
in the file. {Vi cannot handlecharacters in the file at all}
在第一
1 | :[range]s[ubstitute]/{pattern}/{string}/[flags] [count] |
通知
For the
{pattern} see|pattern| .
{string} can be a literal string, or something
special; see|sub-replace-special| .
我知道现在你知道the search和替代模式的不同模式的行动规则。如果你
同时,你需要
(to this part of the shortcut is