如何在可视模式下将文本块保存到Vim中的文件? [英] How can I save a text block in visual mode to a file in Vim?

查看:52
本文介绍了如何在可视模式下将文本块保存到Vim中的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

标题非常具有描述性.以防万一,我举个例子:

The title is very descriptive. Just in case, I will give an example:

START BLOCK1
something
END BLOCK1

START BLOCK2
something
somenthing...
END BLOCK2

  1. 我在可视模式下选择BLOCK1
  2. 我通过按 y
  3. 来取消它
  4. 如何将被选中的BLOCK1保存到其他文件?
  1. I select the BLOCK1 in visual mode
  2. I yank it by pressing y
  3. How can I save the yanked BLOCK1 to some other file?

推荐答案

以线形或块形模式选择要保存的文本,并且

Select the text you wish to save, in either line visual or block visual mode, and

:w new.txt

这是您键入的内容,但实际上您不会真正地看到上面的内容.当您按下:时,您将转到命令行,该命令行将自动填充选择信息.看起来像这样:

That's what you type, but you won't actually see exactly what's above. When you press :, you'll go to the command line which will automatically get filled in with selection information. It'll look something like this:

:'<,'>

只需继续输入其余的(w new.txt)即可

Just carry on typing the rest (w new.txt) to get

:'<,'>w new.txt

...然后按Enter.

...and press enter.

这篇关于如何在可视模式下将文本块保存到Vim中的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆