使用Sed,我想替换这条长行:
http://download.lenovo.com/UserFiles/Driver/en/Downloads%20and%20Drivers/Z570/Win7/IN3ETN46WW5.exehttp://download.lenovo.com/UserFiles/Driver/en/Downloads%20and%20Drivers/Z570/Win%207%20Update/IN1AUD25WW5.exehttp://download.lenovo.com/UserFiles/Driver/en/Downloads%20and%20Drivers/Z570/Win7/IN2VDO61WW6.exehttp://download.lenovo.com/UserFiles/Driver/en/Downloads%20and%20Drivers/Z570/Win7/IN1SRM38WW5.exehttp://download.lenovo.com/UserFiles/Driver/en/Downloads%20and%20Drivers/Z570/Win7/IN2VDO63WW5.exehttp://download.lenovo.com/UserFiles/Driver/en/Downloads%20and%20Drivers/Z570/Win7/IN6WLN49WW5.exe
进入这个:
http://download.lenovo.com/UserFiles/Driver/en/Downloads%20and%20Drivers/Z570/Win7/IN3ETN46WW5.exe
http://download.lenovo.com/UserFiles/Driver/en/Downloads%20and%20Drivers/Z570/Win%207%20Update/IN1AUD25WW5.exe
http://download.lenovo.com/UserFiles/Driver/en/Downloads%20and%20Drivers/Z570/Win7/IN2VDO61WW6.exe
我试过(在vim里面)
:%s#http://#\nhttp://#g
它不起作用。
有什么建议吗?
答案 0 :(得分:3)
由于某些原因vim
需要替换\r
,所以如果您将替换更改为:
:%s#http://#\r&#g
它会起作用。
如果您不介意额外的空格,这将适用于sed
:
sed 's#http://#\n&#g' infile