1

I would like to run some command on each .js file of project. Argument list seems like a perfect usecase for it.

:arga **/*.js
:argdo 'some_command'

The problem is that using :arga **/*.js adds all .js files also to buffer list, which is an unintended side effect for me. It is possible to add files to argument list without adding them to buffer list?

I could write a script which remembers buffer list and restores it but there should be a better way.

  • I have read only about doing the opposite. I think you cant because any intent to edit a file creates a buffer. – Saul Axel Martinez Ortiz Jul 9 '18 at 2:17
2

:h args has the following lines:

    `If you give more than one file name when starting Vim, this list is
    remembered as the argument list.  You can jump to each file in this
    list.

    Do not confuse this with the buffer list, which you can see with the
    |:buffers| command.  The argument list was already present in Vi, the
    buffer list is new in Vim.  Every file name in the argument list will
    also be present
    in the buffer list (unless it was deleted with |:bdel| or |:bwipe|).  But it's
    common that names in the buffer list are not in the argument list.`

So it seems adding files to a args list also adds it to the buffers list. As mentioned in the docs... perhaps you can use :bdel to delete them from the args list.

Ref:

  1. http://vimhelp.appspot.com/editing.txt.html#argument-list

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.