Last matching text was not replaced by %s

Linus Arver linusarver at gmail.com
Sun May 24 04:47:30 CEST 2015


On Sun, May 24, 2015 at 10:35:08AM +0800, LiuXiaogang wrote:
> Hi,
> I isntalled evil-mode version 20150511.146 from melpa yesterday. I tried the following command line
> :%s/get-line/getLine/
> As you can see from the attached picture, the last match was not highlighted (and not replaced when I hit Enter). I have haskell-mode installed and was editing a simple haskell file. Below is the source code. The green text was the one missed by the command.
> getLines :: (Num a) => [String] -> a -> [String]getLines [] n = []getLines xs@(x:_) n  | length xs < n = [] -- Ignore remainder  | otherwise     = (get-line (take n xs)) : (getLines (drop n xs))
> get-line :: [String] -> Stringget-line [] = "\n"get-line (x:xs) = (show x) + "," + (get-line xs)
> 

The behavior you are seeing is not a bug. This is actually the correct
behavior of standard Vim also. You have to pass in the `/g` flag, like
this:

    :%s/get-line/getLine/g

to replace all matches. Without that flag, the replacement will only
occur 1 time per physical line of text.

Cheers,
Linus



More information about the implementations-list mailing list