1 統計出現次數
:%s/178//ng
文本test
711[10.235.170.22:8123] 0 10.232.20.178 1648042 1648042 0 2013-07-29 20:01:35711[10.235.170.22:8123] 11 10.232.20.178 6445135 6129386 315749 2013-07-29 20:19:40711[10.235.170.22:8123] 129 10.232.20.178 2220052 2220052 0 2013-07-29 19:33:04711[10.235.170.22:8123] 111 10.232.20.178 4939938 4754688 185250 2013-07-29 20:19:40711[10.235.170.22:8123] 123 10.232.20.178 284227 284227 0 2013-07-29 19:33:00711[10.235.170.22:8123] 112 10.232.20.178 4393638 4262994 130644 2013-07-29 20:19:40711[10.235.170.22:8123] 121 10.232.20.178 413891 413891 0 2013-07-29 19:33:00711[10.235.170.22:8123] 130 10.232.20.178 2803552 2803552 0 2013-07-29 19:33:04711[10.235.170.22:8123] 10 10.232.20.178 6558889 6235520 323369 2013-07-29 20:19:40711[10.235.170.22:8123] 106 10.232.20.178 5080974 4886037 194937 2013-07-29 20:19:40:%s/178//ng
結果,總共出現在10行,出現了10次。n,代表只報告匹配個數,不進行實際替換。
10 matches on 10 lines
2 替換匹配項
%s 是替換的意思
:%s/178/ggg
結果是
711[10.235.170.22:8123] 0 10.232.20.ggg 1648042 1648042 0 2013-07-29 20:01:35711[10.235.170.22:8123] 11 10.232.20.ggg 6445135 6129386 315749 2013-07-29 20:19:40711[10.235.170.22:8123] 129 10.232.20.ggg 2220052 2220052 0 2013-07-29 19:33:04711[10.235.170.22:8123] 111 10.232.20.ggg 4939938 4754688 185250 2013-07-29 20:19:40711[10.235.170.22:8123] 123 10.232.20.ggg 284227 284227 0 2013-07-29 19:33:00711[10.235.170.22:8123] 112 10.232.20.ggg 4393638 4262994 130644 2013-07-29 20:19:40711[10.235.170.22:8123] 121 10.232.20.ggg 413891 413891 0 2013-07-29 19:33:00711[10.235.170.22:8123] 130 10.232.20.ggg 2803552 2803552 0 2013-07-29 19:33:04711[10.235.170.22:8123] 10 10.232.20.ggg 6558889 6235520 323369 2013-07-29 20:19:40711[10.235.170.22:8123] 106 10.232.20.ggg 5080974 4886037 194937 2013-07-29 20:19:40
10 substitutions on 10 lines