In Vim visual mode, why does the command start with '<,'>?

前端 未结 5 1080
醉酒成梦
醉酒成梦 2021-01-04 09:47

When I pop into Vim\'s visual mode to, for example, indent a block of text, the command prompt always starts with \'<,\'>. Can someone break down for me w

5条回答
  •  难免孤独
    2021-01-04 10:29

    The '<,'> at the beginning of your command line represents the range which you have selected . This is the also the range of test onto which the command you are about to enter would be applied.

    For example if I selected a region of text in visual mode and then wanted to replace all occurrences of 'stack' with 'overflow' my command would look like:

    :'<,'>s/stack/overflow/g
    

    Without visual mode this same command would have to be accomplished by specifying the line range by hand eg:

    :1,10s/helo/hello/g
    

提交回复
热议问题