How to edit blocks in vim without visual block mode

前端 未结 3 1421
忘掉有多难
忘掉有多难 2021-01-26 04:53

Is there a way to edit a vertical block in a code without using the visual block mode selection?

3条回答
  •  隐瞒了意图╮
    2021-01-26 05:19

    What's so bad about blockwise visual mode?! There's no practical alternative to it.

    • You could use :substitute with atoms like \%>v, \%, \%>l and \% to limit the pattern match to a rectangular block, but that's very tedious.
    • There are some multi-edit plugins (inspired by other editors) that allow you to select some areas, and then simultaneously edit them all.
    • For special purposes, you could write a scriptlet / mapping with getline() / setline() and String manipulation in Vimscript.

提交回复
热议问题