m (Exec cmd for each in a OPENBRACKET glob CLOSEBRACKET list in moved to Execute command on each file in a list: Page moved by JohnBot to improve title) |
(Change <tt> to <code>, perhaps also minor tweak.) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{review}} |
{{review}} |
||
+ | {{TipImported |
||
− | {{Tip |
||
|id=1230 |
|id=1230 |
||
+ | |previous=1229 |
||
− | |title=exec cmd for each in a __OPENBRACKET__glob__CLOSEBRACKET__ list in |
||
+ | |next=1231 |
||
− | |created= |
+ | |created=2006 |
|complexity=basic |
|complexity=basic |
||
− | |author= |
+ | |author=Eric Arnold |
|version=n/a |
|version=n/a |
||
|rating=0/0 |
|rating=0/0 |
||
+ | |category1= |
||
− | |text= |
||
+ | |category2= |
||
− | |||
− | |||
⚫ | |||
− | |||
⚫ | |||
− | |||
− | |||
− | |||
⚫ | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
⚫ | |||
− | |||
⚫ | |||
− | |||
⚫ | |||
− | |||
− | |||
− | |||
⚫ | |||
− | |||
⚫ | |||
− | |||
⚫ | |||
− | |||
⚫ | |||
− | |||
⚫ | |||
− | |||
⚫ | |||
− | |||
⚫ | |||
− | |||
⚫ | |||
− | |||
⚫ | |||
− | |||
− | endif |
||
− | |||
⚫ | |||
− | |||
− | endfor |
||
− | |||
⚫ | |||
− | |||
⚫ | |||
− | |||
⚫ | |||
− | |||
⚫ | |||
− | |||
− | endfor |
||
− | |||
⚫ | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
}} |
}} |
||
⚫ | |||
+ | <pre> |
||
⚫ | |||
+ | </pre> |
||
⚫ | |||
⚫ | |||
− | Is this to do: |
||
+ | <pre> |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
+ | endif |
||
⚫ | |||
+ | endfor |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
+ | endfor |
||
⚫ | |||
+ | </pre> |
||
⚫ | |||
− | or with Vim 7 |
||
⚫ | |||
− | :n file*.[ch] | tab sball |
+ | or with Vim 7 <code>:n file*.[ch] | tab sball</code> |
− | Or am I missing something? |
||
− | |||
− | Bheeshmar |
||
− | , May 13, 2006 20:47 |
||
---- |
---- |
||
⚫ | |||
− | |||
⚫ | |||
− | |||
− | |||
− | eric_p_arnold--AT--yahoo.com |
||
− | , May 14, 2006 3:15 |
||
---- |
---- |
||
− | <!-- parsed by vimtips.py in 0.695977 seconds--> |
Latest revision as of 06:14, 13 July 2012
Tip 1230 Printable Monobook Previous Next
created 2006 · complexity basic · author Eric Arnold · version n/a
I wanted to do
:new file*.[ch]
and have each file show up in a new window, without having to mess up the args list or whatever. I came up with the following script.
command! -nargs=* -complete=file New call Foreach( "new %% ", <f-args> ) command! -nargs=* -complete=file Vnew call Foreach( "vnew %% ", <f-args> ) command! -nargs=* -complete=file Diff call Foreach( "vnew %% | diffthis", <f-args> ) " %% symbols are replaced with file/arg names function! Foreach( ... ) let cmd = a:1 "echomsg 'cmd='.cmd . ',0:'.a:0.',all:'.string(a:000) let fnames = [] for i in range( 1, a:0 - 1 ) let l = split( glob( a:000[i] ), "\n" ) if len( l ) < 1 let l = [ a:000[i] ] endif call extend( fnames, l ) endfor for fname in fnames let cmd1 = substitute( cmd, '%%', fname, 'g' ) exe cmd1 "echomsg cmd1 endfor endfunction
Comments[]
Is this to do :n file*.[ch] | sball
or with Vim 7 :n file*.[ch] | tab sball
sball
isn't workable if you already have a big buffer list of other stuff.