在 Vim 中,选择、删除或注释掉大部分多屏文本的最佳方法是什么? [英] In Vim, what is the best way to select, delete, or comment out large portions of multi-screen text?

查看:26
本文介绍了在 Vim 中,选择、删除或注释掉大部分多屏文本的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Eclipse 等 IDE 中选择大量跨多个屏幕的文本相当容易,因为您可以使用鼠标,但最好的方法是例如选择和删除多屏文本块或编写,例如三个大方法放到另一个文件中,然后在 Vim 中删除它们以进行测试,当通过 putty/ssh 使用它时,您无法使用鼠标?

Selecting a large amount of text that extends over many screens in an IDE like Eclipse is fairly easy since you can use the mouse, but what is the best way to e.g. select and delete multiscreen blocks of text or write e.g. three large methods out to another file and then delete them for testing purposes in Vim when using it via putty/ssh where you cannot use the mouse?

我可以轻松地拖到行尾或代码块的末尾,但是如果文本扩展到多个屏幕上,或者其中有很多空行,我感觉我的手被 Vim 束缚了.有什么解决办法吗?

I can easily yank-to-the-end-of-line or yank-to-the-end-of-code-block but if the text extends over many screens, or has lots of blank lines in it, I feel like my hands are tied in Vim. Any solutions?

还有一个相关的问题:有没有办法以某种方式选择 40 行,然后将它们全部注释掉(使用#"或//"),这在大多数 IDE 中很常见?

And a related question: is there a way to somehow select 40 lines, and then comment them all out (with "#" or "//"), as is common in most IDEs?

推荐答案

嗯,首先,你可以设置 vim 与鼠标一起工作,这将允许你像你一样选择文本将在 Eclipse 中.

Well, first of all, you can set vim to work with the mouse, which would allow you to select text just like you would in Eclipse.

默认情况下,您还可以使用视觉选择 - v.选择后,您可以yankcut

You can also use the Visual selection - v, by default. Once selected, you can yank, cut, etc.

至于注释掉块,我通常用VISUAL选择它,然后做

As far as commenting out the block, I usually select it with VISUAL, then do

:'<,'>s/^/# /

# 替换每一行的开头.('<'> 标记是视觉选择的开始和和.

Replacing the beginning of each line with a #. (The '< and '> markers are the beginning and and of the visual selection.

这篇关于在 Vim 中,选择、删除或注释掉大部分多屏文本的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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