In Vim, what is the best way to select, delete, or comment out large portions of multi-screen text?

前端 未结 16 1167
醉话见心
醉话见心 2021-01-31 09:43

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 de

16条回答
  •  一生所求
    2021-01-31 10:14

    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.

提交回复
热议问题