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

查看:22
本文介绍了如何将可视模式下的文本块保存到 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

...然后按回车键.

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

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