Home  >  Q&A  >  body text

How to search files in a folder by content with VIM?

vim can use regular expressions to search in a file. Is there a way to search for matching files in a folder?

怪我咯怪我咯2711 days ago904

reply all(5)I'll reply

  • 黄舟

    黄舟2017-05-16 16:44:54

    You can refer to: http://vim.wikia.com/wiki/Find_in_fil...

    reply
    0
  • 给我你的怀抱

    给我你的怀抱2017-05-16 16:44:54

    Recommended Grep.vim plug-in

    http://www.vim.org/scripts/script.php...

    After entering :Grep in the vim command line, the grep plug-in will prompt you to enter the keywords to be found, and then
    For the file type you are looking for, press Enter to perform the search, and the search results will be listed in quickfix (note, vim and
    Many external commands and plug-in interaction information will be presented in quickfix).

    If you want to suddenly change the case, execute it

    :Grep -i

    If you want to search subdirectories recursively, execute it

    :Grep -r

    If you execute the :Grep command in a non-blank space, the grep plug-in will automatically search for the word currently under the cursor as a keyword

    Separating line

    grep.vim will open the quickfix window
    :cwOpen the quickfix window:cw打开 quickfix 窗口
    :q:qExit quickfix

    reply
    0
  • 天蓬老师

    天蓬老师2017-05-16 16:44:54

    Yes. See details

    :help grep

    reply
    0
  • 天蓬老师

    天蓬老师2017-05-16 16:44:54

    Use ack

    reply
    0
  • 阿神

    阿神2017-05-16 16:44:54

    grep -rl

    reply
    0
  • Cancelreply