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?
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?
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?
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
.
You can also use the Visual selection - v, by default. Once selected, you can yank
, cut
, etc.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With