Wikia

Vim Tips Wiki

Use :next to search for files in the current directory

Talk0
1,612pages on
this wiki
Revision as of 07:51, July 7, 2009 by JohnBeckett (Talk | contribs)

Tip 1535 Printable Monobook Previous Next

created December 1, 2007 · complexity basic · author Yaojg · version 7.0


Vim's find only accepts exact file names. It does not accept wild chars like * and **.

:next is good way to search for files in the current directory.

For example, if the current directory is d:/vim/reason,

:next **/*Filter.java

searchs all the files in d:/vim directory recursively to find files whose names are suffixed with Filter.java.

:help :next

Comments

 TO DO 

  • Explain the point of this tip, as opposed to using other tools that may be more suited to the task.
  • Can the built-in :Explore command be used?
  • Shouldn't the help be to :next_f rather than :next?
  • The "for example" is unnecessarily confusing. There is no reason to have an example with "vim" in the path. Also, delete the "d:" – it serves no purpose.
  • Does the command really search the parent directory like the words suggest?

Is there a way to make it search the full path, and not just current directory?

Rough merge in of material by User talk:Chuck Forbish

I use the following mappings to iterate through files in my argument list (:args).

nmap <c-right> :n<CR>
nmap <c-left> :N<CR>

Using control and an arrow key is much faster than typing ':cn<CR>'.

Similarly you can use the up and down arrows for going back and forth for the times there is more than one matching tag.

nmap <C-Down> :tn<CR>
nmap <C-Up> :tN<CR>

These key sequences support repeating if kept pressed.


Around Wikia's network

Random Wiki