Edit Page
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 380: | Line 380: | ||
command! -nargs=* Find :call Find(<f-args></pre> |
command! -nargs=* Find :call Find(<f-args></pre> |
||
+ | |||
− | ---- |
||
Modified above function to use the -path parameter instead of -iname, this allows things like: |
Modified above function to use the -path parameter instead of -iname, this allows things like: |
||
− | <pre> |
||
:Find 'log*htt*err*' /var |
:Find 'log*htt*err*' /var |
||
− | </pre> |
||
Which would find /var/log/httpd/error_log |
Which would find /var/log/httpd/error_log |
||
− | <pre> |
||
Find 'pub*.tpl' |
Find 'pub*.tpl' |
||
− | </pre> |
||
Which would find all .tpl files in public_html |
Which would find all .tpl files in public_html |
||
⚫ | |||
− | <pre> |
||
⚫ | |||
⚫ | |||
− | + | let path=a:1<br> |
|
− | let |
+ | let query=a:2<br> |
− | + | else<br> |
|
⚫ | |||
⚫ | |||
− | let |
+ | let query=a:1<br> |
− | + | endif<br> |
|
+ | <br> |
||
⚫ | |||
⚫ | |||
− | |||
+ | let ignore = ""<br> |
||
⚫ | |||
− | + | else<br> |
|
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
+ | <br> |
||
⚫ | |||
+ | let l:list=system("find ".path." -type f -path '".query."'".ignore)<br> |
||
− | |||
− | let l: |
+ | let l:num=strlen(substitute(l:list, "[^\n]", "", "g"))<br> |
+ | <br> |
||
⚫ | |||
⚫ | |||
− | |||
+ | echo "'".query."' not found"<br> |
||
⚫ | |||
− | + | return<br> |
|
− | + | endif<br> |
|
+ | <br> |
||
⚫ | |||
+ | if l:num == 1<br> |
||
− | |||
⚫ | |||
⚫ | |||
⚫ | |||
− | exe "open " . substitute(l:list, "\n", "", "g") |
||
+ | let tmpfile = tempname()<br> |
||
− | else |
||
− | + | exe "redir! > " . tmpfile<br> |
|
− | + | silent echon l:list<br> |
|
− | + | redir END<br> |
|
− | + | let old_efm = &efm<br> |
|
− | + | set efm=%f<br> |
|
+ | <br> |
||
− | set efm=%f |
||
+ | if exists(":cgetfile")<br> |
||
− | |||
− | + | execute "silent! cgetfile " . tmpfile<br> |
|
⚫ | |||
− | execute "silent! |
+ | execute "silent! cfile " . tmpfile<br> |
− | else |
||
⚫ | |||
− | execute "silent! cfile " . tmpfile |
||
+ | <br> |
||
− | endif |
||
+ | let &efm = old_efm<br> |
||
− | |||
+ | <br> |
||
⚫ | |||
⚫ | |||
− | |||
⚫ | |||
⚫ | |||
+ | <br> |
||
⚫ | |||
⚫ | |||
− | |||
⚫ | |||
⚫ | |||
⚫ | |||
− | endif |
||
⚫ | |||
⚫ | |||
⚫ | |||
− | </pre> |