Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change auto-complete behaviour in vim?

Tags:

vim

Explain by example.

I want to split my window and open file-x.txt

In the folder where I am working I also have the set of files: from file-a.txt to file-z.txt

If I type:

:sp fileTab

Instead of getting :sp file- As I usually get in bash.

I get: :sp file-a.txt

This is not very convenient as I need to either tap Tab ridiculous times or type really long names.

Is there a way to set the auto-complete behaviour for VIM for file names?

Thank you for your time.

like image 254
pedrosaurio Avatar asked Jul 16 '12 11:07

pedrosaurio


2 Answers

You can use a wildcard here:

:sp *x<Tab>

In the scenario you describe, hitting a single <Tab> should complete the command-line to:

:sp file-x.txt

like image 40
romainl Avatar answered Nov 03 '22 00:11

romainl


The 'wildmode' setting controls the completion in the command line. Try

:set wildmode=longest:full,full

This should achieve the desired effect.

like image 164
Ingo Karkat Avatar answered Nov 03 '22 00:11

Ingo Karkat