Wikia

Vim Tips Wiki

Changes: Use :next to search for files in the current directory

Edit

Back to page

(rough merge in of material placed on an obsolete redirect page by Chuck Forbish (2008-12-14))
(Change <tt> to <code>, perhaps also minor tweak.)
 
Line 3: Line 3:
 
|previous=1534
 
|previous=1534
 
|next=1536
 
|next=1536
|created=December 1, 2007
+
|created=2007
 
|complexity=basic
 
|complexity=basic
 
|author=Yaojg
 
|author=Yaojg
Line 13: Line 13:
 
Vim's find only accepts exact file names. It does not accept wild chars like * and **.
 
Vim's find only accepts exact file names. It does not accept wild chars like * and **.
   
'''<tt>:next</tt>''' is good way to search for files in the current directory.
+
'''<code>:next</code>''' is good way to search for files in the current directory.
   
 
For example, if the current directory is d:/vim/reason,
 
For example, if the current directory is d:/vim/reason,
Line 25: Line 25:
 
{{Todo}}
 
{{Todo}}
 
*Explain the point of this tip, as opposed to using other tools that may be more suited to the task.
 
*Explain the point of this tip, as opposed to using other tools that may be more suited to the task.
*Can the built-in <tt>:Explore</tt> command be used?
+
*Can the built-in <code>:Explore</code> command be used?
*Shouldn't the help be to <tt>:next_f</tt> rather than <tt>:next</tt>?
+
*Shouldn't the help be to <code>:next_f</code> rather than <code>:next</code>?
 
*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.
 
*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?
 
*Does the command really search the parent directory like the words suggest?

Latest revision as of 06:31, July 13, 2012

Tip 1535 Printable Monobook Previous Next

created 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

CommentsEdit

 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 ForbishEdit

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