To auto-complete file names while editing files in vi or vim, you can use the Ctrl+X
and Ctrl+F
keys.
When you are in insert mode in vi or vim, you can type the first few characters of a file name, and then press Ctrl+X
followed by Ctrl+F
to auto-complete the file name.
For example, if you want to insert the file /etc/hosts
into your file, you can type /etc/hos
and then press Ctrl+X
followed by Ctrl+F
. This will auto-complete the file name to /etc/hosts
.
If there are multiple files that match the characters that you have typed, vi or vim will display a list of options for you to choose from. You can use the arrow keys to navigate the list of options, and press Enter
to select the file that you want to insert.
You can also use the Ctrl+X
and Ctrl+L
keys to auto-complete a file name or a word in vi or vim. This will match the characters that you have typed against the words in the current file or in a list of words that you specify.
For more information about auto-completion and other features in vi or vim, you can consult the vi or vim documentation or search online for more information.