📅 2016-Oct-06 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ autocomplete, path, vim ⬩ 📚 Archive
It is useful to be able to autocomplete a path to a directory or filename while typing code or script files. This helps in ensuring that there are no mistakes and the path is correct. Thankfully, Vim has an autocompletion feature for typing path in insert mode! It calls this feature as file name completion.
Ctrl-x Ctrl-f
: This is the shortcut to autocomplete path in insert mode. Start typing a path (absolute or relative) and use this keyboard shortcut. You will see a dropdown menu filled with the next entries from the filesystem that can be used to fill the path.
Ctrl-n
or Ctrl-p
: Shortcuts to move up and down the entries in the autocomplete dropdown menu. If you move off the top or bottom of the dropdown menu, you get the empty entry.
Absolute path: Any path that you begin typing with a slash is autocompleted as an absolute path.
Relative path: This is any path that does not begin with a slash. They are autocompleted too. Note that they will use the directory that Vim was launched from (PWD) as the root.
Hidden files or directories: I found that this was autocompleted only if I typed the first period and then used Ctrl-x Ctrl-f
.
Tried with: Vim 7.4 and Ubuntu 14.04