linux - 如何在 vi 编辑器中删除选定的文本

我正在使用 PuTTY 和 vi 编辑器。如果我用鼠标选择了 5 行,我想删除这些行,我该怎么做?

另外,如何使用键盘选择行,就像在 Windows 中按 Shift 并移动箭头以选择文本一样?我如何在 vi 中做到这一点?

最佳答案

I am using PuTTY and the vi editor. If I select five lines using my mouse and I want to delete those lines, how can I do that?

忘记鼠标。要删除 5 行,可以:

  • 到第一行输入d5d(dd删除一行,d5d删除5行)~or~
  • 键入 Shift-v 进入行选择模式,然后使用 j 向下移动光标(是的,使用 hjkl移动向左向下upright,这比使用箭头更有效)并键入 d 删除选择。

Also, how can I select the lines using my keyboard as I can in Windows where I press Shift and move the arrows to select the text? How can I do that in vi?

正如我所说,要么使用 Shift-v 进入逐行选择模式,要么使用 v 进入逐字符选择模式,或者使用 Ctrl-v 进入进入分 block 选择模式。然后用 hjkl 移动。

我建议花一些时间在 Vim Tutor 上(运行 vimtutor),以一种非常具有指导意义的方式更加熟悉 Vim。

另见

  • 此回答 What is your most productive shortcut with Vim? (我最喜欢的关于 SO 的答案之一)。
  • Efficient Editing With vim

https://stackoverflow.com/questions/3114936/

相关文章:

python - 如何检查浮点值是否为整数

linux - 如何管道或重定向 curl -v 的输出?

python - 在文件之间使用全局变量?

android - Eclipse Android 插件 -- libncurses.so.5

linux - 符号链接(symbolic link) : find all files that

linux - 如何在不打开 Linux 的情况下找到所有串行设备(ttyS、ttyUSB、..)?

linux - 如何在 shell 变量中获取网页的内容?

python - 如何在 Django 中过滤 DateTimeField 的日期?

python - Django 的嵌套 Meta 类是如何工作的?

python - 检查一个单词是否在 Python 中的字符串中