vim 重複大段落替換( 刪除)

2021-09-10 04:24:50 字數 2153 閱讀 9709

目標刪除所有重複的注釋段:

nsresult

mozadhoc:: sendextradata (int16_t atype, const nsastring& adata)//todo atype should be int

return ns_ok;

}//執行shell命令

nsresult

mozadhoc:: sendextradata (int16_t atype, const nsastring& adata)//todo atype should be int

return ns_ok;

}//執行shell命令

nsresult

mozadhoc:: sendextradata (int16_t atype, const nsastring& adata)//todo atype should be int

else

return ns_ok;

}//執行shell命令

nsresult

mozadhoc:: sendextradata (int16_t atype, const nsastring& adata)//todo atype should be int

else

return ns_ok;

}//執行shell命令

nsresult

mozadhoc:: sendextradata (int16_t atype, const nsastring& adata)//todo atype should be int

else

return ns_ok;

}//執行shell命令

nsresult

mozadhoc:: sendextradata (int16_t atype, const nsastring& adata)//todo atype should be int

else nsresult

mozadhoc:: sendextradata (int16_t atype, const nsastring& adata)//todo atype should be int

else

return ns_ok;

}//執行shell命令

nsresult

mozadhoc:: sendextradata (int16_t atype, const nsastring& adata)//todo atype should be int

else

return ns_ok;

}//執行shell命令

nsresult

mozadhoc:: sendextradata (int16_t atype, const nsastring& adata)//todo atype should be int

else

return ns_ok;

}//執行shell命令

return ns_ok;

}//執行shell命令

要刪除:

/*

*void *handle = dlopen(dlib_path, rtld_global | rtld_now);

*if (handle == null) else {

* adhoclog("dlopen successed.");

*/

用替換的辦法刪除:

\n^.*$

:%s#if (handle != null) {\n.*$\n.*$\n.*$\n.*$\n.*$\n.*$\n.*$\n.*$#if (handle != null) {#gc

%s#if (handle != null) {\n.*$\n.*$\n.*$\n.*$\n.*$\n.*$\n.*$\n.*$#if (handle != null) {#gc
多少行就多少個$號,

刪除包含某內容的行,

:g/something/d

如:刪除所有 //adhoclog( 的行

:g#//adhoclog(#d

vim 批量刪除 替換 剪下曲線救國

剪下為 游標所在行開始 行數加dd 刪除指定字元 可以參考查詢替換 替換內容為空 1.可用於在選中的行上插入相同的內容 vi 下,如何在每行中插入?類似ultraedit的列編輯 1 定位游標 2 ctrl v 進入visual mode。3 j 選擇要在哪些行加入?4 i 一定是大寫!5 輸入要插...

vim刪除空行 注釋和換行符替換

g d 刪除空行以及只有空格的行 g s d 刪除以 開頭或 空格 或 tab 開頭的行 g s d 對於 php.ini 配置檔案,注釋為 開頭 g s d 刪除從第二行到包含 bbs 的區間行 2,bbs d 刪除從包含 bbs 的行到最後一行區間的行 bbs d 刪除匹配 bbs 且前面只有乙...

vim學習日誌(7) 替換 刪除檔案中的字元

vim全域性替換檔案 語法為 addr s 源字串 目的字串 option 全域性替換命令為 s 源字串 目的字串 g addr 表示檢索範圍,省略時表示當前行。如 1,20 表示從第1行到20行 表示整個檔案,同 1,從當前行到檔案尾 s 表示替換操作 option 表示操作型別 如 g 表示全域...