2015-10-05 58 views
2

命令:/ point a /,/ point b/y在vim中,允許我在以下示例中抽出第2行到第4行。但是,我只想選擇點a和點b之間的文本,而不是完整的行。防止vim拖出整行

---啓動例子---從

b點
---結束例如
副本---

我知道這使用可視化模式或使用標記來實現。但是,我想知道如何使用上述搜索命令等搜索模式來執行此操作。我要尋找的抽出文本是這個:



b點

問候,

回答

0

什麼你可能以後是一個正回顧後發+前瞻。

(?<=group)pattern - 積極lookbehind - 作爲一個模式的單個實例匹配,它繼續指定的組但不包含該組中的匹配。

pattern(?=group) - 積極向上 - 匹配一個模式的單個實例,後面是指定的組,但不包含匹配中的組。

例子:

(?<=pointa)pattern(?=pointb) 
0

這應該爲你工作:

示例文本

copy from point a 
to 
point b 

命令序列

// '(\_s\|.\)*' Matches line breaks or any character 0 or more times. 
/point a\(\_s\|.\)*point b 
// (press enter) 
// Select the matched result in visual mode. 
gn 
// Now yank it. 
y 
// Put it somewhere else. 
p 
// You get : 
// point a 
// to 
// point b 

我認爲yank只能在視覺模式下進行這種選擇,它會在其他情況下複製整個涉及運動的線條。