删除/从当前行到包含搜索模式的行

Sti*_*ony 5 vim latex

假设我有以下文本(光标位于第一个单词“开始”的中间。

blah blah blah blah stuff stuff stuff
\\\begin{tabular}
{
|p{0.25\textwidth}
|p{0.2\textwidth}
|p{0.5\textwidth}
|}
\hline
Item & Type & Notes\\\hline
Text text text text text text text text &
Text text text text text &
Text text text text text text text text text text text text text text text text text
  text text text text text text\\\hline

Installation instructions &
.txt / .html / TBD &
Installation help should be conspicuous but not the central item\\\hline
\end{tabular}
blah blah blah more stuff more stuff
Run Code Online (Sandbox Code Playgroud)

我想把桌子剪下来,把它移到别的地方。线条实际上要长得多,所以它们缠绕了好几次,我无法轻易确定我想要剪掉多少线条。

我输入 d 2 / a r } / e delete 直到“ar}”的第二个匹配在模式的 'e'nd 处停止。

但这从“开始”这个词的中间到我想要剪切的地方结束。我想抓住完整的行,我觉得应该有一个在 6 次以下击键中的快捷方式。我不使用乳胶VIM,因为它不喜欢我的标准的Windows安装GVIM的所以没有,我不能(据我所知)容易从抢\begin来的\end。我很乐意在这方面被证明是错误的。


是的,这个问题可能是 StackExchange 站点的交叉,包括 Tex、StackOverflow 和 Unix。随意建议一个更好的网站来询问这个问题。

rom*_*inl 5

使用 Ex 命令:

:,/\\e/d
Run Code Online (Sandbox Code Playgroud)

分解:

  • Ex 命令的结构::{range}command{address}.
  • 可以使用行号、标记或搜索模式来分隔范围,这里我们从当前行开始,通常是 a.但可以像这里一样跳过,我们以模式匹配结束\end
  • 我们d删除该范围内的行。

结合搜索和上下文标记:

/\\e<CR>
d''
Run Code Online (Sandbox Code Playgroud)

分解:

  • 搜索\e
  • d从这里删除到前一个光标位置的行。

使用视觉模式:

v/\\e<CR>
V
d
Run Code Online (Sandbox Code Playgroud)

分解:

  • 目视选择从这里到\e
  • 切换到视线块。
  • d删除选择中的行。

使用 Ex 命令而不是普通模式命令对上述方法的变化:

v/\\e<CR>
:'<,'>d
Run Code Online (Sandbox Code Playgroud)

分解:

  • 目视选择从这里到\e
  • 使用 进入命令行模式:'<,'>范围将自动插入。
  • d删除选择中的行。