开发者

How can I search for the dot character using the search command?

I'm trying to use the Search command in Vim:

:Rs/F/T/X

R = range
F = text to find
T = text to replace with
X = options

But, when I want to search for the "." (开发者_StackOverflowdot character) I'm getting some problems.

The task: Replace all occurences of " ." (space dot) for ">" (greater-than)

So, first I tried this:

:%s/ ./>/g

But this changed me all the " ." (space ANY-CHARACTER) to the ">" character.

Then I remembered that the dot character is a special one, so I tried this:

:%s/ \./>/g

But vim threw me an error: E486 Can't find pattern " \."

And finally I tried this crazy thing:

:%s/" ."/>/g and this :%s/" \."/>/g

But I got the same result: E486 Can't find pattern...

So, how can I search for the dot character using the search command?

PS: Sorry for my poor English.


Both a space and a dot are special characters. Try this:

:%s/\s\./>/g

Update: \s is used to represent all whitespace characters (space, tab, line break), not just a space.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜