如何在 vi/Vim 中多行选择的开头插入文本 [英] How to insert text at beginning of a multi-line selection in vi/Vim

查看:36
本文介绍了如何在 vi/Vim 中多行选择的开头插入文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Vim中,如何在每一行的开头插入字符在选择中?

In Vim, how do I insert characters at the beginning of each line in a selection?

例如,假设我的语言的注释系统不允许像 /* * 这样的块注释,我想通过在每一行的开头添加 // 来注释掉一个代码块/.我该怎么做?

For instance, I want to comment out a block of code by prepending // at the beginning of each line assuming my language's comment system doesn't allow block commenting like /* */. How would I do this?

推荐答案

  • Esc 进入命令模式"
  • 使用Ctrl+V进入可视块模式
  • 移动 Up/Down 以选择要添加的行中的文本列评论.
  • 然后按 Shift+i 并输入要插入的文本.
  • 然后按Esc,等待1秒,插入的文本将出现在每一行.
    • Press Esc to enter 'command mode'
    • Use Ctrl+V to enter visual block mode
    • Move Up/Downto select the columns of text in the lines you want to comment.
    • Then hit Shift+i and type the text you want to insert.
    • Then hit Esc, wait 1 second and the inserted text will appear on every line.
    • 有关更多信息和阅读,请查看 Vim 中的多行插入文本"提示维基.

      For further information and reading, check out "Inserting text in multiple lines" in the Vim Tips Wiki.

      这篇关于如何在 vi/Vim 中多行选择的开头插入文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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