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

前端 未结 16 1180
醉话见心
醉话见心 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:33

    Use the visual block command v (or V for whole lines and C-V for rectangular blocks). While in visual block mode, you can use any motion commands including search; I use } frequently to skip to the next blank line. Once the block is marked, you can :w it to a file, delete, yank, or whatever. If you execute a command and the visual block goes away, re-select the same block with gv. See :help visual-change for more.

    I think there are language-specific scripts that come with vim that do things like comment out blocks of code in a way that fits your language of choice.

提交回复
热议问题