vimtricks.wiki Concise Vim tricks, one at a time.

How do I keep an argument list change local to the current window?

Answer

:arglocal

Explanation

By default, Vim's argument list is global, so changing it in one window can unexpectedly affect another workflow in a different tab or split. :arglocal gives the current window its own argument list, which is useful when you want focused batch operations without disturbing the rest of your session. This becomes especially powerful when combining :argdo, :next, and quick navigation in side-by-side tasks.

How it works

:arglocal
  • :arglocal detaches the current window from the global argument list
  • After that, :args, :argadd, :argdelete, and :argdo apply only to this window's local list
  • Other windows continue using their existing argument list unchanged

This lets you run targeted refactors or checks in one window while keeping another window's file queue intact.

Example

Window A (global args): app/*.js
Window B (global args): app/*.js

In Window B run :arglocal, then :args tests/**/*.js

Result
- Window A still cycles through app/*.js
- Window B now cycles through tests/**/*.js

Tips

  • Run :args after :arglocal to confirm the local list contents
  • Pair with :argdo for scoped, repeatable edits in just one window context
  • If you want to return to shared behavior, use :argglobal

Next

How do I search for 'bar' that is not preceded by 'foo'?