Reply to message «How to close all files opened by different vim instances.», sent 11:08:22 17 March 2011, Thursday by Forest Wang:
<...>
> vim c&
> ...
>
> Than I realized I need to close all of them. So I had to close them one by
> one:
>
> %1 and :qa!
> %2 and :qa!
> ...
>
> Is there a better way to close all files by issuing one command or one
> script?
If you are on zsh, you could use the following script:
emulate -L zsh
for job in ${(k)jobtexts[(R)vim*|view*]} ; do
kill -TERM "${${(s.=.)${(@s.:.)jobstates[$job]}[3]}[1]}"
# For unknown reason kill -TERM handling is delayed
# until foregrounding, so doing it here. `kill -KILL' is not
# though
%$job
endfor
Note that you could put this into function in ~/.zshrc, but you can't put it
into separate script that will run in another process.
Original message:
> All,
>
> Say, in a terminal, I opened many files by invoking vim or gvim program
> many times, like:
>
> vim a&
> vim b&
> vim c&
> ...
>
> Than I realized I need to close all of them. So I had to close them one by
> one:
>
> %1 and :qa!
> %2 and :qa!
> ...
>
> Is there a better way to close all files by issuing one command or one
> script?
>
> Thanks.
> BR
> Wang, Mengjia
signature.asc
Description: This is a digitally signed message part.
