Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Vim bash-completion

This repository contains a bash-completion file for vim.

The following features are curently supported:

  • auto completion of remote files (vim scp://$host//files)
  • basic argument completion


  • bash and bash-completion
  • vim scp:// completion
    • configure your ssh_config so that you can connect to your hosts by name without any options and ideally without a password prompt everytime
      • using key based authentication with ssh-agent or passwordless keyfiles is preferred
      Host machine
        User account
        IdentityFile ~/.ssh/id_ed25519
        PubkeyAuthentication yes
    • if the completion should be fast you want to enable control sockets
    Host *
      ControlMaster auto
      ControlPath ~/.ssh/sockets/%C
      ControlPersist 15m
    • The directory is not created automatically and can be done with mkdir -p ~/.ssh/sockets/.
    • remove : from COMP_WORDBREAKS which can be done by adding the following line to your bashrc
      • this is required because vim scp://machine//home/user/.bashrc does not use the same format as {rsync,scp} machine:/home/user/.bashrc does but the completion files by bash-completion are re-used
  • clone the repo this repository into some directory git clone ~/.bash_completion.d/vim-bash-completion
  • load the completion file
    • on demand: either symlink (preferred) or copy the vim file into the follwoing directory
      • the directory can be defined by $BASH_COMPLETION_USER_DIR/completions which defaults to $XDG_DATA_HOME/bash-completion/completions which on itself defaults to ~/.local/share/bash-completion/completions
      • See the question Q. Where should I install my own local completions? at the bash-completion faq for details
    • source the vim file in ~/.bash_completion
    • if you do not want to clone the repository you can also copy the function from the vim file into your ~/.bash_completion


I was surprised that I couldn't find any bash-completion script for vim. I also learned a couple of days before the scp:// remote feature in vim which is not that usuable without knowing file paths off the top of your head. I knew that scp and rsync have fantastic bash-completion for remote files which are very responsive if you use ssh sontrol sockets. See man ssh_config and search for ControlMaster.