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

How do I insert all command-line completion matches at once without pressing Tab repeatedly?

Answer

<C-a> (command-line)

Explanation

Pressing <C-a> on the command line expands all current completion matches into the command at once, rather than cycling through them one at a time with <Tab>. This is useful when you want to operate on every match simultaneously — for example, listing all buffers containing a pattern, or loading multiple files at once.

How it works

  • Type a partial command or argument on the : command line
  • Press <C-a> instead of <Tab> to insert all matching completions in one shot
  • Vim inserts each match separated by a space

Example

To see all open buffers whose names contain spec:

:b spec<C-a>

Expands to something like:

:b spec/auth_spec.rb spec/user_spec.rb spec/models/post_spec.rb

Or, to delete all .bak files in one command:

:!rm *.bak<C-a>

To load all files matching a glob into the argument list:

:args src/**/*.go<C-a>

Tips

  • Combine with :b to quickly switch to or close multiple buffers in one line
  • Works with any completable context: file paths, buffer names, command names, options
  • <C-d> (list completions) shows what <C-a> would insert, without actually inserting them
  • Unlike <Tab>, <C-a> does not cycle — it pastes everything immediately

Next

How do I encode and decode JSON data in Vimscript for configuration and plugin development?