Find the next occurrence of a variable in vim

后端 未结 2 781
你的背包
你的背包 2021-01-31 15:06

I would like to know if/how I can make vim look for the next occurrence of a variable. Let\'s say the variable\'s name is simply \'n\', then /n would give me all oc

2条回答
  •  温柔的废话
    2021-01-31 15:39

    If you have the cursor over the variable in question, you can press * and it will search for the next occurrence or # will search for the previous one.

    This is equivalent to typing:

    /\
    

    (\< matches on the start of a word and \> matches on the end of word). The only difference (for reasons I'm not sure of) is that * and # don't pay attention to the 'smartcase' option.

    See:

    :help *
    :help /\<
    

提交回复
热议问题