Last matching text was not replaced by %s
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) Best regards,Xiaogang
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
Xiaogang, As Linus already noted, you propably forgot the `/g` flag. The g flag means global – each occurrence in the line is changed, rather than just the first. I guess you got this, because you're accustomed to have the default setting for the 'gdefault' option on in your Vimrc configuration. Without the `gdefault` option, it requires that the g flag should be included in %s///g to perform a global substitute. I recommend to set your gdefault to be turned off, it creates confusion because then %s/// is global, whereas %s///g is not (that is, g reverses its meaning). Thus as expected, Evil is showing the correct behaviour of a Vim implementation. 2015-05-24 4:35 GMT+02:00 LiuXiaogang <[email protected]>:
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] -> String* *get-line [] = "\n"* *get-line (x:xs) = (show x) + "," + (get-line xs)*
Best regards, Xiaogang
_______________________________________________ implementations-list mailing list [email protected] https://lists.ourproject.org/cgi-bin/mailman/listinfo/implementations-list
-- Sent from my Vmail client. <http://danielchoi.com/software/vmail.html>
participants (3)
-
Ernst de Hart -
Linus Arver -
LiuXiaogang