sponsor Vim development Vim logo Vim Book Ad

vim-alias : versatile vim-command line aliases

 script karma  Rating 13/4, Downloaded by 2516  Comments, bugs, improvements  Vim wiki

created by
Enno Nagel
script type
This plugin lets you define command-line abbreviations by `:Alias` which only expand at the beginning of the command prompt.

You can pass the optional parameters

  -buffer  or  -range

to create a buffer local alias or one that accepts a range preceding the

These command line abbreviations work like the bash aliases, except that
the alias is substituted in-place.

# Usage

    :Alias [-range] [-buffer] <lhs> <rhs>
    :UnAlias <lhs> ...
    :Aliases [<lhs> ...]

## Examples:

    :Alias   -range   dg   <c-r>=&l:diff?"diffget":"dg"<cr>
    :Alias   -buffer  spl  setlocal\ spell<bar>setlocal\ spelllang=en
    :Alias            w!!  write\ !sudo\ tee\ >\ /dev/null\ %
    :Alias            F    find\ *<c-r>=EatChar("\ ")<cr>
    :Alias            th   tab\ help
    :Alias            sft  setfiletype
    :Alias            g    !git
    :UnAlias          g

  See :help abbreviations for Eatchar(c).

## Persistent Aliases:

To define the Aliases after Vim has started up, put them in ~/.vim/after/plugin/alias.vim (on Linux) or %USERPROFILE%/vimfiles/after/plugin/alias.vim (on Microsoft Windows).

# Configuration

The variable `g:cmdaliasCmdPrefixes` lists the patterns of all commands by
which an alias command may be preceded and yet expand. It defaults to

  let g:cmdaliasCmdPrefixes = [
      \ '\d*verb\%[ose]', 'debug', 'sil\%[ent]!\?', '\%uns[ilent]' 'redir\?!\?',
      \ 'ld!\?', '[cl]fd!\?', '[cl]f\?do!\?',
      \ '\%(\%([.$]\|\d\+\)\%([,;]\%([.$]\|\d\+\)\)*\)\?\s*' .
      \ '\%(argdo\?!\?\|bufdo\?!\?\|windo\?\|tabdo\?\)' ]

# Development

vim-alias is developed at


where issues can be filed.

# Credits

This plugin builds and improves on cmdalias.vim 3. 0 by Hari Krishna Dara by

- allowing for aliases of commands preceded by a range (like :Alias -range dg
- allowing for alias names ending in non-word chars (like :Alias w!! ...),
- having a Vim documentation, and
- more checks for proper usage, more consistent parameter parsing and a finer
  check for blanks or commands (such as :  silent! ) preceding the alias.
install details
Unpack vim-alias into ~/.vim on Linux or Mac and into %USERPROFILE%/vimfiles on Microsoft Windows.

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
vim-alias.zip 1.7 2019-09-13 6.0 Enno Nagel autoloadize
vim-alias.zip 1.6 2019-09-06 6.0 Enno Nagel allow overriding alias, fix two errors
vim-alias.zip 1.5 2018-05-10 6.0 Enno Nagel separate strictly between buffer-local and global aliases
vim-alias.zip 1.4 2016-11-02 7.0 Enno Nagel Handle Aliases that extend each other and end in non-word characters
vim-alias.zip 1.2 2016-06-13 7.0 Enno Nagel fix minor quirks
vim-alias.zip 1.1 2016-04-09 7.0 Enno Nagel - secure alias names & expansions
- extend doc
- minor bug fix
vim-alias.zip 1.0 2016-04-06 7.0 Enno Nagel Initial upload
ip used for rating:

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.