search

Home  >  Q&A  >  body text

How to search all files in a directory in vim

You can use ctrl+shift+f in a general editor to conveniently search all files under a certain directory (or project). How to achieve this in vim?

怪我咯怪我咯2773 days ago743

reply all(5)I'll reply

  • 为情所困

    为情所困2017-05-16 16:42:37

    The simplest: :vimgrep /{pattern}/ /yourpath
    Traverse the search results using:
    :cprev[ious] Previous file :cprev[ious] 前一个文件
    :cnext 下一个文件
    :cfirst 第一个文件
    :clast:cnext Next file

    :cfirst First file 🎜 :clast The last file🎜

    reply
    0
  • 漂亮男人

    漂亮男人2017-05-16 16:42:37

    Make it simple, install the plug-in. What you want is to search based on the file name. We recommend CtrlP, Command-T, FuzzFinder, Unite, etc. Start with CtrlP or CommandT. After you are familiar with it, you can try the more powerful Unite. .

    reply
    0
  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-05-16 16:42:37

    Find in files within Vim

    For example, if I want to search for layout in the current directory, I only need:

    :lvim /\<\(house\|home\)\>/gj *
    

    Then use the following command to display the query results:

    :lw
    

    Screenshots are as follows:

    You can also read this article: Search multiple files with :vimgrep

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-05-16 16:42:37

    Recommend exVim
    Searching for symbols is very convenient
    For non-symbolic text (such as Chinese), use vimgrep

    as mentioned above

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-05-16 16:42:37

    1. Install ag or ack
    2. Execute the following command in VIM :set grepprg=ag

    reply
    0
  • Cancelreply