sponsor Vim development Vim logo Vim Book Ad

ArgsAndMore : Apply commands to multiple buffers and manage the argument list.

 script karma  Rating 7/4, Downloaded by 397    Comments, bugs, improvements  Vim wiki

created by
Ingo Karkat
 
script type
utility
 
description
DESCRIPTION
This plugin supports you with batch processing many files by extending the
built-in :windo, :argdo, etc. commands. You can filter the argument list,
add files _not_ matching a pattern, convert between arguments and quickfix
list, and apply arbitrary Ex commands (also partially) via :Argdo, then
analyze any errors and retry on an argument list where the successfully
processed arguments have been removed.

RELATED WORKS
- The :ArgsNegated command was inspired by the following Stack Overflow
  question:
    http://stackoverflow.com/questions/11547662/how-can-i-negate-a-glob-in-vim
- The https://github.com/nelstrom/vim-qargs plugin has a :Qargs command
  similar (but more simplistic) than :CListToArgs.

USAGE
:Bufdo {cmd}            Execute {cmd} in each buffer in the buffer list, then
                        return back to the original one.
                        Any encountered errors are also put into the
                        quickfix list.

:BufdoWrite {cmd}       Execute {cmd} in each buffer in the buffer list and
                        automatically persist any changes (:update).

:Windo {cmd}            Execute {cmd} in each window, then return back to the
                        original one.

:Winbufdo {cmd}         Execute {cmd} in each different buffer shown in one of
                        the windows in the current tab page (once per buffer),
                        then return back to the original one.

:Tabdo {cmd}            Execute {cmd} once in each tab page, then return back
                        to the original one.

:Tabwindo {cmd}         Execute {cmd} in each open window on each tab page,
                        then return back to the original one.

:Argdo {cmd}            Execute {cmd} for each file in the argument list, then
                        return back to the original file and argument.
:{range}Argdo {cmd}     Execute {cmd} for the {range} of indices from the
                        argument list, then return back to the original file
                        and argument.
                        For example, to execute {cmd} on the remaining
                        arguments, use :.,$Argdo {cmd}

                        In contrast to :argdo, this also avoids the
                        hit-enter prompt (all files will be processed
                        without further interaction from you), and an error
                        summary will be printed.
                        To work on the errors / arguments with errors, you can
                        use :ArgdoErrors and :ArgdoDeleteSuccessful.
                        Also, any encountered errors are put into the
                        quickfix list.

:ArgdoWrite {cmd}       Execute {cmd} in each buffer in the argument list and
                        automatically persist any changes (:update).
:ArgdoConfirmWrite {cmd}
                        Like :ArgdoWrite, but confirm each write, allowing
                        to review the automatically applied changes of {cmd}
                        before persisting them. When you quit the argument
                        processing before the last argument, this will not
                        return to the original file (to make it easier to
                        process the remaining arguments again).

:ArgdoErrors            List all error messages that occurred during the last
                        :Argdo command, and for each unique error, print the
                        argument number and filespec.

:ArgdoDeleteSuccessful  Delete those arguments from the argument list that
                        didn't cause any error messages during the last
                        :Argdo command.

:ArgsFilter {expr}      Apply the filter() of {expr} to the argument list,
                        and keep only those where {expr} yields true. This
                        allows you to :argdelete multiple arguments at once
                        and to delete without specifying the full filename.

:ArgsNegated[!] {arglist}
                        Define all files except {arglist} as the new argument
                        list and edit the first one.

:ArgsList[!]            List each argument number and filespec in a neat list
                        (not just one after the other as :args). With [!],
                        expand all arguments to absolute filespecs.
:ArgsList[!] {glob}     List each argument number and filespec that matches
                        (with [!]: does not match) {glob} in a neat list.
                        Matching and printing is done to the full filespec.

:ArgsToQuickfix         Show all arguments as a quickfix list.

:CListToArgs            Convert the files in the quickfix list to arguments.
:[count]CListToArgsAdd

:LListToArgs            Convert the files in the window's location list to
:[count]LListToArgsAdd  arguments.

:CList[!], :LList[!]    List each file that has listed errors in the quickfix
                        / location list in a neat list. With [!], expand all
                        to absolute filespecs.
:CList[!] {glob}        List each file that has listed errors in the quickfix
:LList[!] {glob}        / location list that matches (with [!]: does not
                        match) {glob} in a neat list. Matching and printing is
                        done to the full filespec.
 
install details
INSTALLATION
This script is packaged as a vimball. If you have the "gunzip" decompressor
in your PATH, simply edit the *.vmb.gz package in Vim; otherwise, decompress
the archive first, e.g. using WinZip. Inside Vim, install by sourcing the
vimball or via the :UseVimball command.
    vim ArgsAndMore*.vmb.gz
    :so %
To uninstall, use the :RmVimball command.

DEPENDENCIES
- Requires Vim 7.0 or higher.
- Requires the ingo-library.vim plugin (vimscript #4433), version 1.017 or
  higher.

CONFIGURATION
After each {cmd}, an extra Ex command (sequence) can be executed. By default,
a delay of 100 ms is introduced here. This allows you to abort an interactive
:s///c substitution by pressing CTRL-C twice within the delay. (Without the
delay, it may or may not abort.) To also persist any changes to the buffer,
you could use:
    let g:ArgsAndMore_AfterCommand = 'update | sleep 100m'

During :argdo, syntax highlighting of freshly loaded buffers is turned off for
performance reasons, but for interactive commands, it is useful to have syntax
highlighting. Therefore, the :Argdo and :Bufdo commands detect interactive
commands and overrule the default syntax suppression then. By default, this
applies to the :substitute command with the :s_c flag; you can adapt the
pattern to match other commands, too:
    let g:ArgsAndMore_InteractiveCommandPattern = '...'
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
ArgsAndMore-1.22.vmb.gz 1.22 2014-03-24 7.0 Ingo Karkat - Add :CList and :LList, analog to :ArgsList.
- FIX: :ArgsList printed "cnt" is zero-based, not 1-based.
- Add :ArgdoConfirmWrite variant of :ArgdoWrite.
- Also catch custom exceptions and errors caused by the passed user command (or configured post-command). *** You need to update to ingo-library (vimscript #4433) version 1.017! ***
ArgsAndMore-1.21.vmb.gz 1.21 2013-11-22 7.0 Ingo Karkat - FIX: Use the rules for the /pattern/ separator as stated in :help E146 in the default of g:ArgsAndMore_InteractiveCommandPattern.
- Minor: Exclude further special buffers from syntax enabling.
- :ArgsList also handles ** and [...] wildcards.
- Move escapings.vim into ingo-library. *** You need to update to ingo-library (vimscript #4433) version 1.014! ***
ArgsAndMore-1.20.vmb.gz 1.20 2013-07-19 7.0 Ingo Karkat - Add dependency to ingo-library (vimscript #4433). *** You need to separately install ingo-library (vimscript #4433) version 1.007 (or higher)! ***
- ENH: Add :ArgdoWrite and :BufdoWrite variants that also perform an automatic :update.
- ENH: Add errors from :Argdo and :BufDo to the quickfix list to allow easier rework.
- Avoid script errors when using :Argdo 3s/foo/bar
- ENH: Enable syntax highlighting on :Argdo / :Bufdo on freshly loaded buffers when the command is an interactive one (:s///c, according to g:ArgsAndMore_InteractiveCommandPattern), but for performance reasons not in the general case.
- In :{range}Argdo, emulate the behavior of the built-in :argdo to disable syntax highlighting during to speed up the iteration, but consider our own enhancement, the exception for interactive commands.
ArgsAndMore-1.11.vmb.gz 1.11 2013-01-21 7.0 Ingo Karkat FIX: Factor out s:sort() and also use numerical sort in the one missed case.
ArgsAndMore-1.10.vmb.gz 1.10 2012-09-10 7.0 Ingo Karkat - Add g:ArgsAndMore_AfterCommand hook before buffer switching and use this by default to add a small delay, which allows for aborting an interactive s///c substitution by pressing CTRL-C twice within the delay.
- Add :Bufdo command for completeness, to get the new hook, and the enhanced error reporting of :Argdo.
ArgsAndMore-1.01.vmb.gz 1.01 2012-08-28 7.0 Ingo Karkat - Do not use <f-args> because of its unescaping behavior.
- FIX: "E480: No match" on :ArgsNegated with ../other/path relative argument; need to issue a dummy :chdir to convert relative args before doing the :argdelete.
ArgsAndMore.vba.gz 1.00 2012-07-30 7.0 Ingo Karkat Initial upload
ip used for rating: 54.87.47.251

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
SourceForge.net Logo