Searching word in vim?

前端 未结 4 1635
说谎
说谎 2021-01-29 18:21

I can search word in vim with /word. How can I search only for word, excluding searches for word1 and word2?

相关标签:
4条回答
  • 2021-01-29 18:56
    1. vim filename
    2. press /
    3. type word which you want to search
    4. press Enter
    0 讨论(0)
  • 2021-01-29 18:59

    If you are working in Ubuntu,follow the steps:

    1. Press / and type word to search
    2. To search in forward press 'SHIFT' key with * key
    3. To search in backward press 'SHIFT' key with # key
    0 讨论(0)
  • 2021-01-29 19:01

    For basic searching:

    • /pattern - search forward for pattern
    • ?pattern - search backward
    • n - repeat forward search
    • N - repeat backward

    Some variables you might want to set:

    • :set ignorecase - case insensitive
    • :set smartcase - use case if any caps used
    • :set incsearch - show match as search
    0 讨论(0)
  • 2021-01-29 19:06

    like this:

    /\<word\>
    

    \< means beginning of a word, and \> means the end of a word,

    Adding @Roe's comment:
    VIM provides a shortcut for this. If you already have word on screen and you want to find other instances of it, you can put the cursor on the word and press '*' to search forward in the file or '#' to search backwards.

    0 讨论(0)
提交回复
热议问题