How to enable case insensitive filename completion in Vim

Vim with case insensitive filename autocompletion
Vim with case insensitive filename autocompletion

Opening files and directories from inside Vim can be a bit irritating. This is because it expects you to type the correct case sensitive prefix of the filename or directory before you can autocomplete it by pressing Tab. There are two problems here: Vim wants you to type the prefix and the prefix needs to match the filename with correct case. The second problem here can now be fixed in 7.3 and later versions of Vim.

The wildignorecase option can be set to enable Vim to perform case insensitive autocompletion of filename or directories.

To set it in your .vimrc use:

set wildignorecase

If you use your .vimrc across older and newer versions of Vim, then you might want to check for this option before you set it:

if exists("&wildignorecase")
    set wildignorecase
endif

Tried with: Vim 7.3 and Ubuntu 12.04

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.