[問題] 如何刪除開頭有註解的

看板RegExp (正規表示式 Regular Expression)作者 (oversky0)時間15年前 (2009/10/25 22:40), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串1/2 (看更多)
我想用 grep 在 vim 內抓出論文的大綱。 :vimgrep /section{\|epsfig/ 結果如下 \section{Introduction} \section{Background and Problem Formulation} \centering\epsfig{file=figs/fig1-1.eps,angle=0,width=3.2in} \section{Proposed Technique:\\ Phase Partition Method} \subsection{A Suboptimal Subset of Nodes} %%%\subsection{Dividing the Available Sensor Nodes in Suboptimal \section{Simulation Results} \subsection{Proof of concept} \epsfig{file=figs/fig11.eps,width=3.3in}\\ % \epsfig{file=figs/fig25.eps,width=3.3in}\\ %\subsection{Effect of number of sensors} %\epsfig{file=figs/fig68.eps,width=2.30in}\\ \epsfig{file=figs/fig68.eps,width=2.30in}\\ \section{Discussion and Future Work} % \section{Discussion} \section{Conclusion} 請問要如何改才能避掉開頭有 % 註解的那幾行? 因為註解的格式沒有用的很整齊,變得有點複雜。 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 128.211.253.111 ※ 編輯: oversky0 來自: 128.211.253.111 (10/25 22:52)

10/26 06:14, , 1F
vim 內部搜尋:/^[^%]*\(section{\|epsfig\)
10/26 06:14, 1F
謝謝,後來發現抓圖的 caption 比較好,再修改一下你的方案成 /^[\s]*\\\(sub\)*section{\\|^[\s]*\\caption{/ % 這樣連 subsection, subsubsection 都能抓到,結果如下: \section{Introduction} \section{Background and Problem Formulation} \caption{Concept of distributed beamforming. The chosen nodes form a \section{Proposed Technique:\\ Phase Partition Method} \subsection{A Suboptimal Subset of Nodes} \caption{Normalized power as function of relative phase difference \subsection{Dividing the Available Sensor Nodes in Suboptimal \subsubsection{Test1} \subsubsection{Test2} \caption{Sensor distribution as a function of phase. The Phase \section{Simulation Results} \subsection{Proof of concept} \caption{Proof of concept. $M=100, \rho=1 \lambda.\ \overline D_{max} = \subsection{Effect of Distribution Radius} \caption{Effect of distribution radius.} \subsection{Effect of number of sensors} \caption{Effect of number of sensors.} \subsection{Effect of phase uncertainty} \caption{Effect of phase uncertainty. $M=1000$, $\rho=100 \lambda$. All \section{Discussion and Future Work} \section{Conclusion} 有辦法再進化成下面那樣樹狀結構嗎? Introduction Background and Problem Formulation Fig: Concept of distributed beamforming. The chosen nodes form a Proposed Technique:\\ Phase Partition Method A Suboptimal Subset of Nodes Fig: Normalized power as function of relative phase difference Dividing the Available Sensor Nodes in Suboptimal Test1 Test2 大概還要加上 1. 取 { } 中的字,不過有的 } 被折到下一行了 2. 在 subsection 前加一個 TAB 3. 在 subsubsection 前加兩個 TAB 4. 在 caption 前加 一個 TAB 及 fig: 不過要判斷 caption 是在那一層可能還要加上上下文分析才行。 ※ 編輯: oversky0 來自: 128.211.253.111 (10/26 08:35) ※ 編輯: oversky0 來自: 128.211.253.111 (10/26 08:38)
文章代碼(AID): #1Av6DVP1 (RegExp)
文章代碼(AID): #1Av6DVP1 (RegExp)