2013-10-10 54 views
-1

之間能否請你告訴我怎麼這樣每一段由第一個數字排序:VIM排序是什麼模式

14 Time=110.07s (1541s) Lock=0.00s (0s) Rows=0.1 (1), afadil[afadil]@economiste-www.avantis.pl 
    SELECT t.word AS realword, i.word FROM search_total t LEFT JOIN search_index i ON t.word = i.word WHERE i.word IS NULL 

10 Time=56.60s (566s) Lock=0.00s (0s) Rows=14.6 (146), afadil[afadil]@economiste-www.avantis.pl 
    SELECT n.nid FROM node n LEFT JOIN search_dataset d ON d.type = 'S' AND d.sid = n.nid WHERE d.sid IS NULL OR d.reindex <> N ORDER BY d.reindex ASC, n.nid ASC LIMIT N, N 

1 Time=51.00s (51s) Lock=0.00s (0s) Rows=0.0 (0), afadil[afadil]@economiste-www.avantis.pl 
    SELECT SUM(i.score * t.count) AS score FROM search_index i INNER JOIN search_total t ON i.word = t.word INNER JOIN node n ON n.nid = i.sid INNER JOIN search_dataset d ON i.sid = d.sid AND i.type = d.type WHERE n.status = N AND (n.type NOT IN ('S','S','S','S','S','S','S','S','S','S','S','S','S','S','S','S','S','S','S','S','S','S','S','S')) AND (i.word = 'S' OR i.word = 'S' OR i.word = 'S' OR i.word = 'S' OR i.word = 'S') AND i.type = 'S' AND (d.data LIKE 'S' AND d.data LIKE 'S' AND d.data LIKE 'S' AND d.data LIKE 'S' AND d.data LIKE 'S' AND d.data LIKE 'S' AND d.data LIKE 'S' AND d.data LIKE 'S' AND d.data LIKE 'S') GROUP BY i.type, i.sid HAVING COUNT(*) >= N ORDER BY score DESC LIMIT N, N 

這是一個mysql的日誌,所以我想將它整理出來,每行開頭一個號碼。 預先感謝您。

回答

3

如果您的每一個條目都是單行線,這應該這樣做:

%sort! n 

這種種的第一n棕土,以及!反轉排序順序降序。

由於格式是每個數據集三行,身份證第一:join在一起:

:%g/^\d/join 3 

甲加入用於動態(非固定的行號)的段落是

:%g/^\d/normal! V}J 

(linewise視覺模式,下一段,J oin)。

如果您需要保留單獨的行,您可以使用:substitute(與\r替換)在排序後再次拆分它們。

+0

我在我的vim中粘貼了OP的數據,SQL語句'SELECT ...'分別坐在一行... – Kent

+0

我需要整個段落,它必須保持原樣以獲取完整的信息,謝謝無論如何,但它不回答我的問題。 –

+0

@AbdelilahBenaou:你的問題並不清楚(「每一行都以數字開頭」)。我已經擴展了我的答案來處理這個問題。 –