2012-11-08 42 views

回答

6

單程:對第一行執行:substitute,然後在以下行上用:&&重複相同的替換。

:execute '1s/foo/bar' | 5&& | 11&& | 15&& 

另一種方法:使用:global命令,只有在線路相匹配的模式。

:g/\%1l\|\%5l\|\%11l\|\%15l/s/foo/bar 

第三條道路:使用一個循環:

:for l in [1,5,11,15] | execute l.'s/foo/bar' | endfor 
+0

完美,謝謝@Ingo_Karkat!我非常喜歡3種不同的選擇。 –

1

你如何拿出行號?如果這是目視檢查的手動過程,則可以使用multiselect plugin。它允許你選擇多個非連續的範圍,然後你可以在它們上應用一個命令:

:MSExecCmd s/foo/bar